Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Reading from a stream</li> </ol> <p>The fact that <code>getline()</code> "will automatically enlarge the block of memory as needed" means that this could be used as a denial-of-service attack, as it would be trivial to generate an input that was so long it would exhaust the available memory for the process (or worse, the system!). Once an out-of-memory condition occurs, other vulnerabilities may also come into play. The behaviour of code in low/no memory is rarely nice, and very hard to predict. IMHO it is safer to set reasonable upper bounds on everything, especially in security-sensitive applications.</p> <p>Furthermore (as you anticipate by mentioning special characters), <code>getline()</code> only gives you a buffer; it does not make any guarantees about the contents of the buffer (as the safety is entirely application-dependent). So sanitising the input is still an essential part of processing and validating user data.</p> <ol start="2"> <li>sscanf</li> </ol> <p>I would tend to prefer to use a regular expression library, and have very narrowly defined regexps for user data, rather than use <code>sscanf</code>. This way you can perform a good deal of validation at the time of input.</p> <ol start="3"> <li><p>General comments</p> <ul> <li>Fuzzing tools are available which generate random input (both valid and invalid) that can be used to test your input handling</li> <li>Buffer management is critical: buffer overflows, underflows, out-of-memory</li> <li>Race conditions can be exploited in otherwise secure code</li> <li>Binary files could be manipulated to inject invalid values or oversized values into headers, so file format code must be rock-solid and not assume binary data is valid</li> <li>Temporary files can often be a source of security issues, and must be carefully managed</li> <li>Code injection can be used to replace system or runtime library calls with malicious versions</li> <li>Plugins provide a huge vector for attack</li> <li>As a general principle, I would suggest having clearly defined interfaces where user data (or any data from outside the application) is assumed invalid and hostile until it is processed, sanitised and validated, and the only way for user data to enter the application </li> </ul></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload