2 ms·
Good point. I suppose that you are talking about overwriting terminating NUL, do I get it right? puts() is vulnurable in exactly same way.
by senozhatsky 7y ago
Good point.
I suppose that you are talking about overwriting terminating NUL, do I get it right? puts() is vulnurable in exactly same way.
- shakna 7y agoNo, a format string attack. If you replace the start of the string with various specifiers, you can lift out pointer addresses and write to them. You can't do that with puts. Worst you can do with puts is read.
- senozhatsky 7y agoOK, understood. So what you meant was more like puts()'s attack surface is smaller than printf()'s. This is not how your message appeared to me - "printf() is vulnerable to injections, use puts() instead". Both are vulnerable to "unintended read()-s".
- shakna 7y agoNot really. printf is vulnerable to both read and _write_ attacks when you misuse it by only supplying the single argument. It's vulnerable to injections that can lead to remote execution and all sorts of CVEs. puts is sometimes vulnerable to read attacks, but not often.