This document details a few steps and decisions taken to ensure vsftpd is free
of common implementation flaws.
Tackling the buffer overflow
============================
Probably the most common implementation flaw causing security problems is the
buffer overflow. Buffer overflows come in many shapes and sizes - overflows
onto the stack, overflows off the end of dynamically malloc()'ed areas,
overflows into static data areas. They range from easy to spot (where a user
can put an arbitrary length string into a fixed size buffer), to very
difficult to spot - buffer size miscalculations or single byte overflows. Or
convoluted code where the buffer's definition and various usages are far
apart.
The problem is that people insist on replicating buffer size handling code
and buffer size security checks many times (or, of course, they omit size
checks altogther). It is little surprise, then, that sometimes errors creep
in to the checks.
The correct solution is to hide the buffer handling code behind an API. All
buffer allocating, copying, size calculations, extending, etc. are done by
a single piece of generic code. The size security checks need to be written
once. You can concentrate on getting this one instance of code correct.
From the client's point of view, they are no longer dealing with a buffer. The
buffer is encapsulated within the buffer API. All modifications to the buffer
safely go through the API. If this sounds familiar, it is because what vsftpd
implements is very similar to a C++ string class. You can do OO programming
in C too, you know ;-)
A key point of having the buffer API in place is that it is MORE DIFFICULT to
abuse the API than it is to use it properly. Try and create a buffer memory
corruption or overflow scenario using just the buffer API.
Unfortunately, secure string/buffer usage through a common API has not caught
on much, despite the benefits it brings. Is it under publicised as a solution?
Or do people have too much sentimental attachment to strcpy(), strlen(),
malloc(), strcat() etc? Of notable exception, it is my understanding that at
least the rather secure qmail program uses secure buffer handling, and I'd
expect that to extend to all Dan Bernstein software. (Let me know of other good
examples).
This document details a few steps and decisions taken to ensure vsftpd is free
of common implementation flaws.
Tackling the buffer overflow
============================
Probably the most common implementation flaw causing security problems is the
buffer overflow. Buffer overflows come in many shapes and sizes - overflows
onto the stack, overflows off the end of dynamically malloc()'ed areas,
overflows into static data areas. They range from easy to spot (where a user
can put an arbitrary length string into a fixed size buffer), to very
difficult to spot - buffer size miscalculations or single byte overflows. Or
convoluted code where the buffer's definition and various usages are far
apart.
The problem is that people insist on replicating buffer size handling code
and buffer size security checks many times (or, of course, they omit size
checks altogther). It is little surprise, then, that sometimes errors creep
in to the checks.
The correct solution is to hide the buffer handling code behind an API. All
buffer allocating, copying, size calculations, extending, etc. are done by
a single piece of generic code. The size security checks need to be written
once. You can concentrate on getting this one instance of code correct.
From the client's point of view, they are no longer dealing with a buffer. The
buffer is encapsulated within the buffer API. All modifications to the buffer
safely go through the API. If this sounds familiar, it is because what vsftpd
implements is very similar to a C++ string class. You can do OO programming
in C too, you know ;-)
A key point of having the buffer API in place is that it is MORE DIFFICULT to
abuse the API than it is to use it properly. Try and create a buffer memory
corruption or overflow scenario using just the buffer API.
Unfortunately, secure string/buffer usage through a common API has not caught
on much, despite the benefits it brings. Is it under publicised as a solution?
Or do people have too much sentimental attachment to strcpy(), strlen(),
malloc(), strcat() etc? Of notable exception, it is my understanding that at
least the rather secure qmail program uses secure buffer handling, and I'd
expect that to extend to all Dan Bernstein software. (Let me know of other good
examples).
การแปล กรุณารอสักครู่..

เอกสารรายละเอียดไม่กี่ขั้นตอน และการตัดสินใจถ่ายเพื่อให้แน่ใจว่า vsftpd ฟรี
ข้อเสียของการใช้งานทั่วไป .
การแก้ปัญหาล้น
============================
อาจจะพบมากที่สุดในการทำให้เกิดปัญหาข้อบกพร่องการรักษาความปลอดภัย
บัฟเฟอร์ล้น ใส่สารบัฟเฟอร์ล้นมาในหลายรูปร่างและขนาด - ล้น
บนกองล้นออกจากปลายแบบไดนามิก malloc()
'ed พื้นที่ล้นในพื้นที่ข้อมูลแบบคงที่ พวกเขาช่วงจากง่ายจุด ( ซึ่งผู้ใช้
สามารถใส่ความยาวเชือกโดยพลการในขนาดคงที่กันชน ) มาก
ยากที่จะจุด - ขนาดบัฟเฟอร์การ miscalculations หรือล้นไบต์เดี่ยว หรือรหัสที่ซับซ้อนและการใช้
นิยามต่าง ๆของบัฟเฟอร์จะห่างไกลกัน
.
ปัญหาคือคนยืนยันในคำตอบ บัฟเฟอร์ขนาด
การจัดการรหัสและการรักษาความปลอดภัยขนาดบัฟเฟอร์การตรวจสอบหลายๆ ครั้ง ( หรือ , แน่นอนพวกเขาละเว้นการตรวจสอบขนาด
altogther ) มันเป็นเพียงเล็กน้อยแปลกใจแล้ว บางครั้งข้อผิดพลาดในการตรวจสอบคืบ
.
ทางออกที่ถูกต้องเพื่อซ่อนบัฟเฟอร์การจัดการรหัสหลัง API ทั้งหมด
บัฟเฟอร์จัดสรร , คัดลอก , การคำนวน , ขนาดขยาย ฯลฯ จะทำโดย
ชิ้นส่วนของรหัสสินค้า ขนาดตรวจสอบความปลอดภัยจะต้องมีการเขียน
ครั้ง คุณสามารถมีสมาธิในการนี้ หนึ่งตัวอย่างของรหัสที่ถูกต้อง
จากจุดของลูกค้าของมุมมองที่พวกเขาจะไม่เผชิญกับบัฟเฟอร์
บัฟเฟอร์จะห่อหุ้มภายใน Buffer API ทั้งหมดเพื่อปรับเปลี่ยนบัฟเฟอร์
ได้อย่างปลอดภัยผ่าน API หากเสียงนี้ที่คุ้นเคย มันเป็นเพราะ อะไร vsftpd
ใช้จะคล้ายกับ C String Class คุณสามารถทำ OO
c ในการเขียนโปรแกรมด้วยคุณรู้จัก ; - )
เป็นจุดสําคัญของการมี Buffer API ในสถานที่คือว่ามันเป็นเรื่องยากมากที่จะ
ละเมิด API มากกว่าที่จะใช้มันอย่างถูกต้อง และพยายามสร้างบัฟเฟอร์หน่วยความจำ
การทุจริตหรือสถานการณ์ที่ใช้บัฟเฟอร์ล้น API
ขออภัย การใช้เชือก / บัฟเฟอร์ผ่าน API ทั่วไปที่ไม่ได้ติด
มาก แม้ผลประโยชน์ที่จะนำ มันภายใต้การเผยแพร่เป็นโซลูชั่น
หรือมีคนมากเกินไปซาบซึ้งผูกพันกับ strcpy() strlen() malloc() strcat()
, , , และอื่น ๆ เด่นข้อยกเว้น มันเป็นความเข้าใจของฉันที่
อย่างน้อยค่อนข้างปลอดภัยโปรแกรม qmail ใช้บัฟเฟอร์การขนย้าย และผมหวังที่จะขยาย
ทุกแดน เบิร์นโปรแกรม ( ขอทราบตัวอย่างดี ๆ
)
การแปล กรุณารอสักครู่..
