5 DERECHA
linux 6 본문
1. Linux Security
Let's explore each of these Linux security concepts.
1. ASLR (Address Space Layout Randomization) : ASLR is a security technique that randomizes the memory addresses of executable files and shared libraries. By randomizing the address space layout, it becomes more difficult for attackers to exploit memory-related vulnerabilities, such as buffer overflows and code injection attacks. ASLR helps prevent predictable memory layouts, making it harder for attackers to locate and target specific functions or data.
2. Stack Canary : Stack canaries, also known as stack cookies or stack guards, are security measures employed to protect against buffer overflow attacks. A stack canary is a random value placed between the buffer and the function's return address on the stack. Before the function returns, it checks if the canary value is still intact. If it has been modified, indicating a potential buffer overflow, the program terminates to prevent the execution of malicious code.
3. PA (Address Space Layout Randomization) : PA, or Position-Independent Executables (PIE), is a security feature that randomizes the base address of an executable in memory. Similar to ASLR, PA adds an additional layer of security by randomizing the executable's starting memory address, making it harder for attackers to predict memory locations and launch successful attacks.
4. Containerization : Containers provide a lightweight and isolated environment for running applications. They utilize containerization technologies like Docker or LXC (Linux Containers) to package an application along with its dependencies and run it within a container. Containers offer process-level isolation, ensuring that the application running inside a container is isolated from other processes on the host system. This isolation adds an extra layer of security by reducing the attack surface and limiting the impact of potential vulnerabilities.
5. Virtualization : Virtualization involves creating virtual instances of an entire operating system, allowing multiple operating systems to run concurrently on the same physical hardware. Virtualization technologies like KVM (Kernel-based Virtual Machine) or VMware enable the creation of virtual machines (VMs) that can run different operating systems or versions independently. Each VM operates in its isolated environment, providing strong security boundaries and preventing unauthorized access between virtual machines.
6. TEE (Trusted Execution Environment) : TEE is a secure area within a processor that offers a trusted execution environment for running sensitive code and protecting critical data. TEEs provide a secure enclave that is isolated from the rest of the system's software and hardware. They are typically used for executing trusted applications, securing cryptographic operations, protecting sensitive data, and enabling secure communication with external entities. Examples of TEEs include ARM TrustZone and Intel SGX.
7. SGX (Software Guard Extensions) : SGX is an Intel architecture extension that enables the creation of secure enclaves within the processor's memory. SGX allows applications to execute sensitive code and store critical data in isolated enclaves that are protected even from privileged software and hardware. It ensures the confidentiality and integrity of the code and data within the enclave, making it suitable for securing applications that handle sensitive information, such as encryption keys or user credentials.
These Linux security concepts provide various mechanisms to enhance the security of systems and applications, protecting against common vulnerabilities and attacks. Understanding and utilizing these technologies can significantly strengthen the security posture of Linux-based systems.
2. Buffer Over Flow
In this code, we have a function called vulnerableFunction that takes a string input as an argument. The function has a character array buffer of size 8. However, the strcpy function is used to copy the contents of the input string into the buffer. If the length of the input string is larger than the size of the buffer, a buffer overflow occurs.
In the main function, we create a long string input that is larger than the size of the buffer. When vulnerableFunction is called with this long string as the input, the strcpy function overflows the buffer, writing beyond its allocated space. This can lead to memory corruption and unpredictable behavior, potentially allowing an attacker to execute malicious code or overwrite important data.
To mitigate buffer overflow vulnerabilities, it's important to ensure that buffer sizes are correctly managed and that appropriate bounds checking is performed when handling user input or manipulating memory. Techniques like using safe string functions (strncpy, strlcpy) or implementing input validation and sanitization can help prevent buffer overflow vulnerabilities.
3. printf formatter attack in C c
In this code, the program prompts the user for input and uses printf to print the input directly without any validation or sanitization. This can lead to a printf formatter attack, where an attacker can exploit the format string vulnerabilities of printf to leak sensitive information or execute arbitrary code.
Here's an example of how an attacker can exploit this vulnerability:
1. When prompted for input, the attacker enters %s as the input.
2. The %s format specifier in the printf statement expects a corresponding argument of type char* to be printed. However, in this case, the input from the attacker is treated as the format string itself.
3. As a result, the printf function interprets the attacker's input as a format string and tries to access additional arguments that do not exist.
4/Depending on the content of the attacker's input, different effects can occur. For example, the attacker can leak sensitive data from the stack, overwrite memory, or even execute arbitrary code by utilizing other format specifiers like %n.
To prevent printf formatter attacks, it's crucial to validate and sanitize user input. You can enforce strict input constraints, perform input validation, and properly escape or sanitize user-controlled input before using it as a format string in printf or related functions. Additionally, enabling compiler warnings and utilizing secure coding practices can help detect and prevent format string vulnerabilities.
https://bit.ly/3D9XCOz
#코멘토 #코멘토실무PT #실무PT후기