|
|
Subscribe / Log in / New account

Let the compiler do the bounds checking

Let the compiler do the bounds checking

Posted Jan 21, 2025 20:21 UTC (Tue) by mathstuf (subscriber, #69389)
In reply to: Let the compiler do the bounds checking by kreijack
Parent article: A look at the recent rsync vulnerability

Running sanitizers in CI is fine, but it is my understanding that *deploying* sanitized code is not ideal as the sanitizers themselves could introduce vectors (e.g., we have to run our sanitizer test suites under privileged containers because they don't have ptrace permissions otherwise).


to post comments

Let the compiler do the bounds checking

Posted Jan 21, 2025 20:53 UTC (Tue) by excors (subscriber, #95769) [Link]

The documentation says:

> UndefinedBehaviorSanitizer’s runtime is meant for testing purposes and its usage in production environment should be carefully considered from security perspective as it may compromise the security of the resulting executable. For security-sensitive applications consider using Minimal Runtime or trap mode for all checks.
(https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.ht...)

so it sounds like the "-fsanitize=bounds -fsanitize-trap" combination suggested above should be okay, assuming GCC is similar enough to Clang, and assuming you can interpret the documentation's vague "consider" as a genuine assurance about security.

You still need to be careful about -fsanitize=bounds by itself, and about all the other sanitizers:

> AddressSanitizer is a bug detection tool and its runtime is not meant to be linked against production executables. While it may be useful for testing, AddressSanitizer’s runtime was not developed with security-sensitive constraints in mind and may compromise the security of the resulting executable.
(https://clang.llvm.org/docs/AddressSanitizer.html#securit...)

with the same wording for ThreadSanitizer, MemorySanitizer, LeakSanitizer. The other sanitizers don't document security considerations at all (which presumably doesn't mean there's nothing to consider, just they're not going to help you with that considering).

Let the compiler do the bounds checking

Posted Jan 22, 2025 6:59 UTC (Wed) by alison (subscriber, #63752) [Link] (1 responses)

> Running sanitizers in CI is fine, but it is my understanding that *deploying* sanitized code is not ideal

The sanitizers variously make binaries larger and execution time longer as well. Compiling unit tests with the sanitizers makes more sense, and is a great way to find bugs. A code coverage tool will then identify lines which are not covered by tests. Many code bases are tested in precisely this fashion.

The problem with rsync is more likely a case of "your patch is welcome." If more of us pitched in and helped implement such testing, the code we rely on would be a lot safer.

Let the compiler do the bounds checking

Posted Jan 22, 2025 18:54 UTC (Wed) by Heretic_Blacksheep (guest, #169992) [Link]

That's good in theory, but testing only catches problems you're already aware of in areas of known problems. It doesn't catch problems the maintainers (and their helpers) didn't foresee. There's no substitute for outside skilled eyes on essential projects looking for flawed code. Tools only help, not replace. Compared to how widespread rsync is deployed, the number people actually looking at the source code in the past has been miniscule. That will probably change for a while since blood is in the water for the mercenary security researchers.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds