5 ms·
> allocates a buffer on the stack > the length of this is attacker controlled This isn't the first time this has happened (https://www.openwall.com/lists/oss-
by saagarjha 8y ago
> allocates a buffer on the stack
> the length of this is attacker controlled
This isn't the first time this has happened (https://www.openwall.com/lists/oss-security/2019/01/09/3 https://www.openwall.com/lists/oss-security/2019/01/09/3). Uninformed opinion, but can we just like not stack allocate things, especially if their size is attacker-controlled? Linux has already moved away from VLAs for security reasons, I don't see why systemd shouldn't either.
- kccqzy 8y agoLinux has the option of simply refusing your request and returning -ENOMEM. Is this an option for systemd?
- saagarjha 8y agoI don't see how this would help in this case? If systemd could detect it was going to overflow the stack, there's no vulnerability…
- kccqzy 8y agoI mean, if we avoid stack allocation, then perhaps we need to instead allocate on the heap. What if malloc fails then? Can systemd return an error code? Or do we instead have a DoS problem?
- saagarjha 8y ago> Linux has the option of simply refusing your request and returning -ENOMEM. Is this an option for systemd? > if we avoid stack allocation, then perhaps we need to instead allocate on the heap That's what the fix does: https://github.com/systemd/systemd/commit/f519a19bcd5afe674a9b8fc462cd77d8bad403c1#diff-88d4b05d65f1377f716024145dc65d16 https://github.com/systemd/systemd/commit/f519a19bcd5afe674a...
- jancsika 8y agoWhat are the examples of VLA-related bugs in the Linux kernel like? Are they as stark as this one?
- pjmlp 8y agoCheck the Kernel Security Protection Project sponsored by Google, they are the ones driving the removal of all VLA uses on the kernel.
- userbinator 8y agoThe critical point is unboundedly attacker-controlled sizes. A reasonable limit, specified and then carried into the implementation, would've prevented this bug easily. Speaking of limits, this is something that I think deserves more attention in education --- does the algorithm or code you create work for all inputs, especially those at the limits? Are you even able to determine those limits? Why does a path in D-Bus need to have a 32-bit length? Is 16 (64K) or even 8 (255) bits sufficient? If not, why? Can it be made sufficient? Asking the important questions, learning, and understanding is ultimately going to be a far more useful than the current "just cut off the limb" attitude toward security that seems so prevalent today. Those questions should've all been asked and clearly answered at the design stage.
- saagarjha 8y agoRather, I'd say the critical points are that systemd has critical issues it absolutely should not be having, with the state of tooling we have today (taint analysis, heck, even a good linter might have been able to find this!). When the last thing came out someone I know told me that they had just glanced through the codebase and were not surprised that it had bugs like this; I think his exact words were something like "you don't have code like this in 2019".
- flukus 8y ago> Why does a path in D-Bus need to have a 32-bit length? Is 16 (64K) or even 8 (255) bits sufficient? I'm not sure what path is in this context but if I assume file path (the rest of my post will look stupid if it's not) then 16 seems more than enough, but 8 has bitten many people in the windows world before. I'm also unsure of the context, is it always a path or is it a generic message that will be a path in this context? If it's the latter then there are many instances where 32-bit makes sense and then regardless of what is suitable for a path the 32-bit length is the contract.
- viraptor 8y agoWeirdly, having this stack-allocated probably saved the day a bit. If it was on the heap, there's a good chance that instead of an unmapped page, you'd hit something actually available.
- rurban 8y agoRust loves it and has no intention to secure/fix it neither. They even call it "memory-safe".