1+ <!DOCTYPE qhelp PUBLIC
2+ "-//Semmle//qhelp//EN"
3+ "qhelp.dtd">
4+ <qhelp >
5+ <overview >
6+ <p >Using unsanitized untrusted data in an external API can cause a variety of security issues. This query reports
7+ all external APIs that are used with untrusted data, along with how frequently the API is used, and how many
8+ unique sources of untrusted data flow to this API. This query is designed primarily to help identify which APIs
9+ may be relevant for security analysis of this application.</p >
10+
11+ <p >An external API is defined as a call to a function that is not defined in the source code, and is not
12+ modeled as a taint step in the default taint library. External APIs may be from the C++ standard library,
13+ third party dependencies or from internal dependencies. The query will report the function name, along with
14+ either <code >[param x]</code >, where <code >x</code > indicates the position of the parameter receiving the
15+ untrusted data or <code >[qualifier]</code > indicating the untrusted data is used as the qualifier to the
16+ function call.</p >
17+
18+ </overview >
19+ <recommendation >
20+
21+ <p >For each result:</p >
22+
23+ <ul >
24+ <li >If the result highlights a known sink, no action is required.</li >
25+ <li >If the result highlights an unknown sink for a problem, then add modeling for the sink to the relevant query.</li >
26+ <li >If the result represents a call to an external API which transfers taint, add the appropriate modeling, and
27+ re-run the query to determine what new results have appeared due to this additional modeling.</li >
28+ </ul >
29+
30+ <p >Otherwise, the result is likely uninteresting. Custom versions of this query can extend the <code >SafeExternalAPIFunction</code >
31+ class to exclude known safe external APIs from future analysis.</p >
32+
33+ </recommendation >
34+ <example >
35+
36+ <p >If the query were to return the API <code >fputs [param 1]</code >
37+ then we should first consider whether this a security relevant sink. In this case, this is writing to a <code >FILE*</code >, so we should
38+ consider whether this is an XSS sink. If it is, we should confirm that it is handled by the XSS query.</p >
39+
40+ <p >If the query were to return the API <code >strcat [param 1]</code >, then this should be
41+ reviewed as a possible taint step, because tainted data would flow from the 1st argument to the 0th argument of the call.</p >
42+
43+ <p >Note that both examples are correctly handled by the standard taint tracking library and XSS query.</p >
44+ </example >
45+ <references >
46+
47+ </references >
48+ </qhelp >
0 commit comments