The jump to address stored in a register technique[edit]The

The jump to address stored in a reg

The jump to address stored in a register technique[edit]
The "jump to register" technique allows for reliable exploitation of stack buffer overflows without the need for extra room for a NOP-sled and without having to guess stack offsets. The strategy is to overwrite the return pointer with something that will cause the program to jump to a known pointer stored within a register which points to the controlled buffer and thus the shellcode. For example, if register A contains a pointer to the start of a buffer then any jump or call taking that register as an operand can be used to gain control of the flow of execution.[11]


An instruction from ntdll.dll to call the DbgPrint() routine contains the i386 machine opcode for jmp esp.
In practice a program may not intentionally contain instructions to jump to a particular register. The traditional solution is to find an unintentional instance of a suitable opcode at a fixed location somewhere within the program memory. In figure E on the left you can see an example of such an unintentional instance of the i386 jmp esp instruction. The opcode for this instruction is FF E4.[12] This two byte sequence can be found at a one byte offset from the start of the instruction call DbgPrint at address 0x7C941EED. If an attacker overwrites the program return address with this address the program will first jump to 0x7C941EED, interpret the opcode FF E4 as the jmp esp instruction, and will then jump to the top of the stack and execute the attacker's code.[13]

When this technique is possible the severity of the vulnerability increases considerably. This is because exploitation will work reliably enough to automate an attack with a virtual guarantee of success when it is run. For this reason, this is the technique most commonly used in Internet worms that exploit stack buffer overflow vulnerabilities.[14]

This method also allows shellcode to be placed after the overwritten return address on the Windows platform. Since executables are mostly based at address 0x00400000 and x86 is a Little Endian architecture, the last byte of the return address must be a null, which terminates the buffer copy and nothing is written beyond that. This limits the size of the shellcode to the size of the buffer, which may be overly restrictive. DLLs are located in high memory (above 0x01000000) and so have addresses containing no null bytes, so this method can remove null bytes (or other disallowed characters) from the overwritten return address. Used in this way, the method is often referred to as "DLL Trampolining".

Protective countermeasures[edit]
Various techniques have been used to detect or prevent buffer overflows, with various tradeoffs. The most reliable way to avoid or prevent buffer overflows is to use automatic protection at the language level. This sort of protection, however, cannot be applied to legacy code, and often technical, business, or cultural constraints call for a vulnerable language. The following sections describe the choices and implementations available.

Choice of programming language[edit]
The choice of programming language can have a profound effect on the occurrence of buffer overflows. As of 2008, among the most popular languages are C and its derivative, C++, with a vast body of software having been written in these languages. C provides no built-in protection against accessing or overwriting data in any part of memory; more specifically, it does not check that data written to a buffer is within the boundaries of that buffer. The standard C++ libraries provide many ways of safely buffering data, and C++'s Standard Template Library (STL) provides containers that can optionally perform bounds checking if the programmer explicitly calls for checks while accessing data. For example, a vector's member function at() performs a bounds check and throws an out_of_range exception if the bounds check fails.[15] However, C++ behaves just like C if the bounds check is not explicitly called. Techniques to avoid buffer overflows also exist for C.

Many other programming languages provide runtime checking and in some cases even compile-time checking which might send a warning or raise an exception when C or C++ would overwrite data and continue to execute further instructions until erroneous results are obtained which might or might not cause the program to crash. Examples of such languages include Ada, Eiffel, Lisp, Modula-2, Smalltalk, OCaml and such C-derivatives as Cyclone, Rust and D. The Java and .NET Framework bytecode environments also require bounds checking on all arrays. Nearly every interpreted language will protect against buffer overflows, signaling a well-defined error condition. Often where a language provides enough type information to do bounds checking an option is provided to enable or disable it. Static code analysis can remove many dynamic bound and type checks, but poor implementations and awkward cases can significantly decrease performance. Software engineers must carefully consider the tradeoffs of safety versus performance costs when deciding which language and compiler setting to use.

Use of safe libraries[edit]
The problem of buffer overflows is common in the C and C++ languages because they expose low level representational details of buffers as containers for data types. Buffer overflows must thus be avoided by maintaining a high degree of correctness in code which performs buffer management. It has also long been recommended to avoid standard library functions which are not bounds checked, such as gets, scanf and strcpy. The Morris worm exploited a gets call in fingerd.[16]

Well-written and tested abstract data type libraries which centralize and automatically perform buffer management, including bounds checking, can reduce the occurrence and impact of buffer overflows. The two main building-block data types in these languages in which buffer overflows commonly occur are strings and arrays; thus, libraries preventing buffer overflows in these data types can provide the vast majority of the necessary coverage. Still, failure to use these safe libraries correctly can result in buffer overflows and other vulnerabilities; and naturally, any bug in the library itself is a potential vulnerability. "Safe" library implementations include "The Better String Library",[17] Vstr[18] and Erwin.[19] The OpenBSD operating system's C library provides the strlcpy and strlcat functions, but these are more limited than full safe library implementations.

In September 2007, Technical Report 24731, prepared by the C standards committee, was published;[citation needed] it specifies a set of functions which are based on the standard C library's string and I/O functions, with additional buffer-size parameters. However, the efficacy of these functions for the purpose of reducing buffer overflows is disputable; it requires programmer intervention on a per function call basis that is equivalent to intervention that could make the analogous older standard library functions buffer overflow safe.[20]

Buffer overflow protection[edit]
Main article: Buffer overflow protection
Buffer overflow protection is used to detect the most common buffer overflows by checking that the stack has not been altered when a function returns. If it has been altered, the program exits with a segmentation fault. Three such systems are Libsafe,[21] and the StackGuard[22] and ProPolice[23] gcc patches.

Microsoft's implementation of Data Execution Prevention (DEP) mode explicitly protects the pointer to the Structured Exception Handler (SEH) from being overwritten.[24]

Stronger stack protection is possible by splitting the stack in two: one for data and one for function returns. This split is present in the Forth language, though it was not a security-based design decision. Regardless, this is not a complete solution to buffer overflows, as sensitive data other than the return address may still be overwritten.

Pointer protection[edit]
Buffer overflows work by manipulating pointers (including stored addresses). PointGuard was proposed as a compiler-extension to prevent attackers from being able to reliably manipulate pointers and addresses.[25] The approach works by having the compiler add code to automatically XOR-encode pointers before and after they are used. Because the attacker (theoretically) does not know what value will be used to encode/decode the pointer, he cannot predict what it will point to if he overwrites it with a new value. PointGuard was never released, but Microsoft implemented a similar approach beginning in Windows XP SP2 and Windows Server 2003 SP1.[26] Rather than implement pointer protection as an automatic feature, Microsoft added an API routine that can be called at the discretion of the programmer. This allows for better performance (because it is not used all of the time), but places the burden on the programmer to know when it is necessary.

Because XOR is linear, an attacker may be able to manipulate an encoded pointer by overwriting only the lower bytes of an address. This can allow an attack to succeed if the attacker is able to attempt the exploit multiple times or is able to complete an attack by causing a pointer to point to one of several locations (such as any location within a NOP sled).[27] Microsoft added a random rotation to their encoding scheme to address this weakness to partial overwrites.[28]

Executable space protection[edit]
Main article: Executable space protection
Executable space protection is an approach to buffer overflow protection which prevents execution of code on the stack or the heap. An attacker may use buffer overflows to insert arbitrary code into the memory of a program, but with executable space protection, any attempt to execute that code will cause an exception.

Some CPUs support a feature called NX ("No eXecute") or XD ("eXecute Disabled") bit, which in conjunction with software, can be used to mark pages of data (such as those cont
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Bước tới địa chỉ được lưu trữ trong một kỹ thuật đăng ký [sửa]Kỹ thuật "nhảy để đăng ký" cho phép cho khai thác đáng tin cậy của tràn bộ đệm ngăn xếp mà không cần phải cho thêm chỗ cho NOP sled và mà không cần phải đoán ngăn xếp offsets. Các chiến lược là ghi đè lên con trỏ trở lại với cái gì đó sẽ gây ra chương trình để chuyển đến một con trỏ được biết đến được lưu trữ trong một đăng ký mà điểm đến bộ đệm kiểm soát và do đó shellcode. Ví dụ: nếu đăng ký A chứa một con trỏ đến sự khởi đầu của một bộ đệm sau đó bất kỳ nhảy hoặc gọi tham gia đó đăng ký như là một operand có thể được dùng để giành quyền kiểm soát của dòng chảy thực hiện.[11]Một hướng dẫn từ ntdll.dll gọi thói quen DbgPrint() chứa i386 máy opcode cho jmp esp.Trong thực tế một chương trình có thể không cố ý chứa các hướng dẫn để chuyển đến một đăng ký cụ thể. Giải pháp truyền thống là tìm một thể hiện không chủ ý của một opcode phù hợp tại một vị trí cố định một nơi nào đó trong bộ nhớ chương trình. Trong hình E bên trái, bạn có thể thấy một ví dụ về một thể hiện không chủ ý của hướng dẫn esp jmp i386. Opcode để được hướng dẫn này là FF E4.[12] hai byte chuỗi có thể được tìm thấy tại một bù đắp một byte từ khi bắt đầu cuộc gọi hướng dẫn DbgPrint tại địa chỉ 0x7C941EED. Nếu một kẻ tấn công sẽ ghi đè chương trình trở lại địa chỉ với địa chỉ này chương trình sẽ lần đầu tiên chuyển đến 0x7C941EED, giải thích opcode FF E4 theo hướng dẫn esp jmp, và sẽ sau đó nhảy trên cùng của ngăn xếp và thực thi mã của kẻ tấn công.[13]Khi kỹ thuật này có thể làm tăng mức độ nghiêm trọng của các lỗ hổng đáng kể. Điều này là do khai thác sẽ làm việc đáng tin cậy đủ để tự động hoá một cuộc tấn công với một đảm bảo thành công ảo khi nó được chạy. Vì lý do này, đây là kỹ thuật phổ biến nhất được sử dụng trong Internet sâu mà khai thác lỗ hổng tràn bộ đệm ngăn xếp.[14]Phương pháp này cũng cho phép shellcode được đặt sau khi ghi đè địa chỉ trả lại trên nền tảng Windows. Kể từ khi thực thi được chủ yếu là dựa tại địa chỉ 0x00400000 và x 86 là một chút về cuối kiến trúc, byte cuối của địa chỉ trở lại phải là một null, chấm dứt các bản sao đệm và không có gì viết vượt ra ngoài đó. Điều này giới hạn kích thước của shellcode kích thước bộ đệm, mà có thể quá hạn chế. DLL nằm trong bộ nhớ cao (trên 0x01000000) và do đó có địa chỉ có chứa không có byte trống, vì vậy phương pháp này có thể loại bỏ byte không (hoặc các ký tự không được phép) từ ghi đè địa chỉ trả lại. Sử dụng theo cách này, các phương pháp thường được gọi là "DLL Trampolining".Biện pháp đối phó bảo vệ [sửa]Kỹ thuật khác nhau đã được sử dụng để phát hiện hoặc ngăn chặn tràn bộ đệm, với nhiều cân bằng. Cách đáng tin cậy nhất để tránh hoặc ngăn chặn tràn bộ đệm là sử dụng bảo vệ tự động tại mức ngôn ngữ. Điều này loại bảo vệ, Tuy nhiên, không thể được áp dụng cho mã di sản, và thường kỹ thuật, kinh doanh hoặc văn hóa hạn chế gọi cho một ngôn ngữ dễ bị tổn thương. Phần sau đây mô tả các lựa chọn và triển khai có sẵn.Sự lựa chọn của lập trình ngôn ngữ [sửa]Sự lựa chọn của ngôn ngữ lập trình có thể có một ảnh hưởng sâu sắc đến sự xuất hiện của tràn bộ đệm. Tính đến năm 2008, trong số các ngôn ngữ phổ biến nhất là C và đạo hàm của nó, c + +, với một cơ thể rộng lớn của phần mềm có được viết bằng những ngôn ngữ này. C cung cấp không bảo vệ được xây dựng trong chống lại truy cập hoặc ghi đè lên dữ liệu trong bất kỳ phần nào của bộ nhớ; cụ thể hơn, nó không kiểm tra dữ liệu bằng văn bản để một bộ đệm nằm trong ranh giới của bộ đệm đó. Các thư viện chuẩn C++ cung cấp nhiều cách để một cách an toàn bộ đệm dữ liệu, và thư viện mẫu tiêu chuẩn C++ của (STL) cung cấp các thùng chứa tùy chọn có thể thực hiện giới hạn kiểm tra nếu các lập trình viên một cách rõ ràng cuộc gọi cho kiểm tra trong khi truy cập vào dữ liệu. Ví dụ, một vector thành viên chức năng at() thực hiện một kiểm tra giới hạn và ném một ngoại lệ out_of_range nếu các giới hạn kiểm tra thất bại.[15] Tuy nhiên, C++ cư xử giống như C nếu việc kiểm tra giới hạn không được gọi là một cách rõ ràng. Kỹ thuật để tránh tràn bộ đệm cũng tồn tại cho C.Nhiều ngôn ngữ lập trình khác cung cấp thời gian chạy kiểm tra và trong một số trường hợp thậm chí biên dịch thời gian kiểm tra mà có thể gửi một cảnh báo hoặc nâng cao một ngoại lệ khi C hoặc c + + sẽ ghi đè lên dữ liệu và tiếp tục thực hiện tiếp tục hướng dẫn cho đến khi sai kết quả thu được mà có thể hoặc không có thể gây ra chương trình sụp đổ. Ví dụ về ngôn ngữ như vậy bao gồm Ada, Eiffel, Lisp, Modula-2, Smalltalk, OCaml và các dẫn xuất C như Cyclone, chất tẩy rửa và mất Các môi trường bytecode Java và .NET Framework cũng yêu cầu các giới hạn kiểm tra trên tất cả mảng. Gần như mọi ngôn ngữ diễn giải sẽ bảo vệ chống lại tràn bộ đệm, báo hiệu một lỗi được xác định rõ tình trạng. Thường khi một ngôn ngữ cung cấp đủ thông tin loại làm giới hạn kiểm tra một tùy chọn được cung cấp để kích hoạt hoặc vô hiệu hóa nó. Phân tích mã tĩnh có thể loại bỏ nhiều động bị ràng buộc và gõ kiểm tra, nhưng việc triển khai nghèo và các trường hợp khó khăn đáng kể có thể làm giảm hiệu suất. Kỹ sư phần mềm một cách cẩn thận phải xem xét sự cân bằng của an toàn so với chi phí hiệu quả khi quyết định mà ngôn ngữ và trình biên dịch thiết lập để sử dụng.Sử dụng các thư viện an toàn [sửa]Vấn đề tràn bộ đệm là phổ biến trong các ngôn ngữ C và c + +, bởi vì họ vạch trần thấp cấp chi tiết representational của bộ đệm như thùng chứa cho các loại dữ liệu. Tràn bộ đệm do đó phải được tránh bằng cách duy trì một mức độ cao của đúng đắn trong mã thực hiện quản lý bộ đệm. Nó cũng lâu đã được khuyến cáo để tránh các chức năng tiêu chuẩn thư viện mà không có giới hạn kiểm tra, chẳng hạn như được, scanf và strcpy. Sâu Morris khai thác một cuộc gọi được trong fingerd.[16]Thư viện loại bài viết và thử nghiệm dữ liệu trừu tượng mà tập trung và tự động thực hiện quản lý bộ đệm, bao gồm giới hạn kiểm tra, có thể làm giảm sự xuất hiện và tác động của tràn bộ đệm. Hai loại chính khối xây dựng dữ liệu bằng các ngôn ngữ trong đó tràn bộ đệm thường xảy ra là dây và mảng; Vì vậy, ngăn chặn tràn bộ đệm trong các loại dữ liệu thư viện có thể cung cấp phần lớn của bảo hiểm cần thiết. Tuy nhiên, nếu không sử dụng các thư viện an toàn một cách chính xác có thể dẫn đến tràn bộ đệm và lỗ hổng khác; và tự nhiên, bất kỳ lỗi trong thư viện chính nó là một lỗ hổng tiềm năng. "An toàn" thư viện thực thi bao gồm "The tốt hơn chuỗi thư viện", [17] Vstr [18] và Erwin.[19] Hệ thống điều hành OpenBSD C thư viện cung cấp các chức năng strlcpy và strlcat, nhưng đây là những hạn chế hơn so với việc triển khai Thư viện đầy đủ an toàn.Tháng 9 năm 2007, báo cáo kỹ thuật 24731, chuẩn bị bởi Ủy ban tiêu chuẩn C đã được xuất bản;[cần dẫn nguồn] nó chỉ định một tập hợp các chức năng mà dựa trên thư viện chuẩn C chuỗi và chức năng I/O, với tham số kích cỡ bộ đệm bổ sung. Tuy nhiên, hiệu quả của các chức năng này cho các mục đích của việc giảm tràn bộ đệm là disputable; nó đòi hỏi sự can thiệp của lập trình viên trên một một chức năng gọi cơ sở đó là tương đương để can thiệp có thể làm cho lớn tương tự như thư viện chuẩn chức năng bộ đệm tràn an toàn.[20]Bộ đệm tràn bảo vệ [sửa]Bài chi tiết: bộ đệm tràn bảo vệBộ đệm tràn bảo vệ được sử dụng để phát hiện các bộ đệm phổ biến nhất tràn bằng cách kiểm tra ngăn xếp đã không được thay đổi khi một chức năng trả về. Nếu nó đã được thay đổi, chương trình ra khỏi với một lỗi phân khúc. Ba hệ thống như vậy là Libsafe, [21] và StackGuard [22] và ProPolice [23] gcc bản vá lỗi.Của Microsoft thực hiện công tác phòng chống cản thực thi dữ liệu (DEP) chế độ rõ ràng bảo vệ con trỏ để xử lý ngoại lệ có cấu trúc (SEH) từ đang được ghi đè.[24]Mạnh mẽ hơn ngăn xếp bảo vệ có thể bằng cách chia tách ngăn xếp trong hai: một cho dữ liệu và một cho chức năng trả về. Phân chia này được trình bày trong ngôn ngữ Forth, mặc dù nó không phải là một quyết định thiết kế dựa trên an ninh. Bất kể, đây không phải là một giải pháp hoàn chỉnh để tràn bộ đệm, như là các dữ liệu nhạy cảm khác hơn so với địa chỉ trả lại có thể vẫn còn được ghi đè.Bảo vệ con trỏ [sửa]Bộ đệm tràn công việc bởi thao tác liên kết (bao gồm cả lưu trữ địa chỉ). PointGuard đã được đề xuất như một phần mở rộng trình biên dịch để ngăn chặn kẻ tấn công có thể thao tác đáng tin cậy con trỏ và địa chỉ.[25] các công trình phương pháp tiếp cận bằng trình biên dịch thêm mã để tự động mã hóa XOR gợi ý trước khi và sau khi chúng được sử dụng. Bởi vì những kẻ tấn công (lý thuyết) không biết những gì giá trị sẽ được sử dụng để mã hóa/giải mã con trỏ, ông không thể dự đoán những gì nó sẽ trỏ đến nếu ông sẽ ghi đè nó với một giá trị mới. PointGuard không bao giờ được phát hành, nhưng Microsoft thực hiện một khởi đầu cách tiếp cận tương tự trong Windows XP SP2 và Windows Server 2003 SP1.[26] thay vì thực hiện con trỏ bảo vệ như là một tính năng tự động, Microsoft đã thêm vào một thói quen API mà có thể được gọi là hoàn toàn theo ý của các lập trình viên. Điều này cho phép cho hiệu suất tốt hơn (vì nó là không được sử dụng tất cả thời gian), nhưng đặt gánh nặng trên các lập trình viên để biết khi nó là cần thiết.Bởi vì XOR là tuyến tính, một kẻ tấn công có thể thao tác một con trỏ được mã hóa bằng cách ghi đè lên các chỉ là các byte thấp của một địa chỉ. Điều này có thể cho phép một cuộc tấn công thành công nếu kẻ tấn công có thể cố gắng khai thác nhiều lần hoặc có thể hoàn thành một cuộc tấn công bằng cách gây ra một con trỏ để trỏ đến một trong các vị trí một số (chẳng hạn như bất kỳ vị trí trong một chiếc xe trượt tuyết NOP).[27] Microsoft thêm một vòng quay ngẫu nhiên để của chương trình mã hóa đến địa chỉ này điểm yếu để một phần ghi đè.[28]Bảo vệ không gian thực thi [sửa]Bài chi tiết: bảo vệ không gian thực thiBảo vệ không gian thực thi là một cách tiếp cận để bảo vệ tràn bộ đệm đó ngăn cản thực thi mã vào ngăn xếp hoặc heap. Một kẻ tấn công có thể sử dụng tràn bộ đệm để chèn mã tùy ý vào bộ nhớ của một chương trình, nhưng với bảo vệ không gian thực thi, bất kỳ nỗ lực để thực thi mã đó sẽ gây ra một ngoại lệ.Một số CPU hỗ trợ một tính năng gọi là NX ("không có thực hiện") hoặc XD ("thực hiện vô hiệu hóa") bit, mà kết hợp với phần mềm, có thể được sử dụng để đánh dấu trang của dữ liệu (chẳng hạn như tiếp
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
The jump to address stored in a register technique[edit]
The "jump to register" technique allows for reliable exploitation of stack buffer overflows without the need for extra room for a NOP-sled and without having to guess stack offsets. The strategy is to overwrite the return pointer with something that will cause the program to jump to a known pointer stored within a register which points to the controlled buffer and thus the shellcode. For example, if register A contains a pointer to the start of a buffer then any jump or call taking that register as an operand can be used to gain control of the flow of execution.[11]


An instruction from ntdll.dll to call the DbgPrint() routine contains the i386 machine opcode for jmp esp.
In practice a program may not intentionally contain instructions to jump to a particular register. The traditional solution is to find an unintentional instance of a suitable opcode at a fixed location somewhere within the program memory. In figure E on the left you can see an example of such an unintentional instance of the i386 jmp esp instruction. The opcode for this instruction is FF E4.[12] This two byte sequence can be found at a one byte offset from the start of the instruction call DbgPrint at address 0x7C941EED. If an attacker overwrites the program return address with this address the program will first jump to 0x7C941EED, interpret the opcode FF E4 as the jmp esp instruction, and will then jump to the top of the stack and execute the attacker's code.[13]

When this technique is possible the severity of the vulnerability increases considerably. This is because exploitation will work reliably enough to automate an attack with a virtual guarantee of success when it is run. For this reason, this is the technique most commonly used in Internet worms that exploit stack buffer overflow vulnerabilities.[14]

This method also allows shellcode to be placed after the overwritten return address on the Windows platform. Since executables are mostly based at address 0x00400000 and x86 is a Little Endian architecture, the last byte of the return address must be a null, which terminates the buffer copy and nothing is written beyond that. This limits the size of the shellcode to the size of the buffer, which may be overly restrictive. DLLs are located in high memory (above 0x01000000) and so have addresses containing no null bytes, so this method can remove null bytes (or other disallowed characters) from the overwritten return address. Used in this way, the method is often referred to as "DLL Trampolining".

Protective countermeasures[edit]
Various techniques have been used to detect or prevent buffer overflows, with various tradeoffs. The most reliable way to avoid or prevent buffer overflows is to use automatic protection at the language level. This sort of protection, however, cannot be applied to legacy code, and often technical, business, or cultural constraints call for a vulnerable language. The following sections describe the choices and implementations available.

Choice of programming language[edit]
The choice of programming language can have a profound effect on the occurrence of buffer overflows. As of 2008, among the most popular languages are C and its derivative, C++, with a vast body of software having been written in these languages. C provides no built-in protection against accessing or overwriting data in any part of memory; more specifically, it does not check that data written to a buffer is within the boundaries of that buffer. The standard C++ libraries provide many ways of safely buffering data, and C++'s Standard Template Library (STL) provides containers that can optionally perform bounds checking if the programmer explicitly calls for checks while accessing data. For example, a vector's member function at() performs a bounds check and throws an out_of_range exception if the bounds check fails.[15] However, C++ behaves just like C if the bounds check is not explicitly called. Techniques to avoid buffer overflows also exist for C.

Many other programming languages provide runtime checking and in some cases even compile-time checking which might send a warning or raise an exception when C or C++ would overwrite data and continue to execute further instructions until erroneous results are obtained which might or might not cause the program to crash. Examples of such languages include Ada, Eiffel, Lisp, Modula-2, Smalltalk, OCaml and such C-derivatives as Cyclone, Rust and D. The Java and .NET Framework bytecode environments also require bounds checking on all arrays. Nearly every interpreted language will protect against buffer overflows, signaling a well-defined error condition. Often where a language provides enough type information to do bounds checking an option is provided to enable or disable it. Static code analysis can remove many dynamic bound and type checks, but poor implementations and awkward cases can significantly decrease performance. Software engineers must carefully consider the tradeoffs of safety versus performance costs when deciding which language and compiler setting to use.

Use of safe libraries[edit]
The problem of buffer overflows is common in the C and C++ languages because they expose low level representational details of buffers as containers for data types. Buffer overflows must thus be avoided by maintaining a high degree of correctness in code which performs buffer management. It has also long been recommended to avoid standard library functions which are not bounds checked, such as gets, scanf and strcpy. The Morris worm exploited a gets call in fingerd.[16]

Well-written and tested abstract data type libraries which centralize and automatically perform buffer management, including bounds checking, can reduce the occurrence and impact of buffer overflows. The two main building-block data types in these languages in which buffer overflows commonly occur are strings and arrays; thus, libraries preventing buffer overflows in these data types can provide the vast majority of the necessary coverage. Still, failure to use these safe libraries correctly can result in buffer overflows and other vulnerabilities; and naturally, any bug in the library itself is a potential vulnerability. "Safe" library implementations include "The Better String Library",[17] Vstr[18] and Erwin.[19] The OpenBSD operating system's C library provides the strlcpy and strlcat functions, but these are more limited than full safe library implementations.

In September 2007, Technical Report 24731, prepared by the C standards committee, was published;[citation needed] it specifies a set of functions which are based on the standard C library's string and I/O functions, with additional buffer-size parameters. However, the efficacy of these functions for the purpose of reducing buffer overflows is disputable; it requires programmer intervention on a per function call basis that is equivalent to intervention that could make the analogous older standard library functions buffer overflow safe.[20]

Buffer overflow protection[edit]
Main article: Buffer overflow protection
Buffer overflow protection is used to detect the most common buffer overflows by checking that the stack has not been altered when a function returns. If it has been altered, the program exits with a segmentation fault. Three such systems are Libsafe,[21] and the StackGuard[22] and ProPolice[23] gcc patches.

Microsoft's implementation of Data Execution Prevention (DEP) mode explicitly protects the pointer to the Structured Exception Handler (SEH) from being overwritten.[24]

Stronger stack protection is possible by splitting the stack in two: one for data and one for function returns. This split is present in the Forth language, though it was not a security-based design decision. Regardless, this is not a complete solution to buffer overflows, as sensitive data other than the return address may still be overwritten.

Pointer protection[edit]
Buffer overflows work by manipulating pointers (including stored addresses). PointGuard was proposed as a compiler-extension to prevent attackers from being able to reliably manipulate pointers and addresses.[25] The approach works by having the compiler add code to automatically XOR-encode pointers before and after they are used. Because the attacker (theoretically) does not know what value will be used to encode/decode the pointer, he cannot predict what it will point to if he overwrites it with a new value. PointGuard was never released, but Microsoft implemented a similar approach beginning in Windows XP SP2 and Windows Server 2003 SP1.[26] Rather than implement pointer protection as an automatic feature, Microsoft added an API routine that can be called at the discretion of the programmer. This allows for better performance (because it is not used all of the time), but places the burden on the programmer to know when it is necessary.

Because XOR is linear, an attacker may be able to manipulate an encoded pointer by overwriting only the lower bytes of an address. This can allow an attack to succeed if the attacker is able to attempt the exploit multiple times or is able to complete an attack by causing a pointer to point to one of several locations (such as any location within a NOP sled).[27] Microsoft added a random rotation to their encoding scheme to address this weakness to partial overwrites.[28]

Executable space protection[edit]
Main article: Executable space protection
Executable space protection is an approach to buffer overflow protection which prevents execution of code on the stack or the heap. An attacker may use buffer overflows to insert arbitrary code into the memory of a program, but with executable space protection, any attempt to execute that code will cause an exception.

Some CPUs support a feature called NX ("No eXecute") or XD ("eXecute Disabled") bit, which in conjunction with software, can be used to mark pages of data (such as those cont
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: