5 ms·
Congratulations, this pattern is responsible for more security bugs than any other. Security should not be an "if" but must. Presumably down to instruction lev
by AstralStorm 7y ago
Congratulations, this pattern is responsible for more security bugs than any other.
Security should not be an "if" but must. Presumably down to instruction level or preferably to hardware that does TLB.
This thing is a likely TOCTOU error. What happens if I pass the check and enter the function just not having the permissions?
The only way this is acceptable is if the code is proven to never do that, preferably to the deepest level possible.
- benj111 7y agoYou're reading an awful lot into one 2 line throwaway example on a different topic. CheckHasPermission() could be permission to update the score on space invaders. Plus how are the other 2 examples in any way better from a security POV.
- mav3rick 7y agoIt was an example. It could very well have been checkForSomeNonCriticalThing(x).
- AstralStorm 7y agoIt's the principle of checking separated from using which is wrong in almost all cases. Instead you should cause and/or handle errors! (Also known in Python as duck typing when applied to types.)
- cakoose 7y agoLike others said, not the point of the example. But even then, there's not enough context to determine if there's a TOCTOU bug. For example, what if it's using an RDBMS transaction?