Risky APIs

Every new scan also looks for calls to dangerous functions in your own source code: SQL queries, operating system commands, eval, file access, outbound HTTP requests, unsafe deserialization and similar. The Risky APIs page in the dashboard lists what was found, with the most serious first.

How risky-API detection works

  • It runs automatically as the Scanning for Risky APIs stage of each scan. There is nothing to turn on.
  • A call is reported only when the dangerous argument is computed at run time, such as a variable or a string built from one. Calls with a fixed value, like os.system("ls -la"), are skipped, because an attacker cannot change them.
  • If the whole argument is passed through a known sanitizer for that kind of call, such as int(x), shlex.quote(x) or escapeHtml(x), the call is not reported. A sanitizer used on only part of the argument does not count.
  • It reads Python, JavaScript and TypeScript, Java, PHP, Go, Ruby and C#. Python is the most accurate, because it is parsed with the language's own syntax tree.
  • Test files, minified or generated files, vendored folders such as node_modules, vendor and dist, and files over 1 MB are skipped.
  • Each repository shows its most recent scan. Scans made before risky-API detection was added are not included, so re-scan a repository to see its results.

Reading the page

Open it from Risky APIs in the dashboard menu, or from View all on the Overview's Top 5 Risky APIs card.

  • Risky calls found is the total across the latest scan of each repository.
  • With user input counts the findings where request data reaches the call. Fix these first.
  • Repos affected shows how many scanned repositories have at least one finding.
  • All and User input only switch between every finding and the user-input ones.

Each affected repository has a card with its branch, scan time, counts and Open report. Its table shows, for every finding, the Severity, the Category with its CWE number, the API that was called, the Location (file and line) and the Confidence.

If a card says the scan hit a time or file limit, the results for that repository are partial. If it says Showing the first N of M findings, the repository had more findings than the page can hold; the counts are still complete.

Severity

Severity describes how serious this kind of weakness is if an attacker controls the argument. It comes from the category of the call, so every SQL call has the same severity, whatever the code around it looks like.

  • Critical: SQL injection, command injection and code execution. These usually give an attacker control of the database, the server or the running code.
  • High: path traversal, cross-site scripting, server-side request forgery, unsafe deserialization, LDAP injection and XPath injection. These usually give access to data, files, internal services or other users' sessions.
  • Medium: open redirects, which enable phishing or token leakage but not access to the server.
  • Low: log injection. It is not checked in normal scans.

One exception: in Python, a command given as a list without shell=True, such as subprocess.run(["ls", x]), is lowered from Critical to Medium. No shell is involved, so an attacker can only add arguments, not run new commands.

info
Severity is not a CVSS score and does not prove a call can be exploited. It is also separate from the severity of vulnerable dependencies in the scan report.

Confidence

Confidence describes how likely it is that an attacker controls the argument in this particular call. It is decided separately from severity, so a finding can be Critical with Dynamic confidence. Use both when deciding what to fix.

BadgeConfidenceWhat it meansWhen it is given
User inputHighThe argument is very likely attacker-controlled.The argument contains request data, or uses a variable that was assigned from request data earlier in the same file.
DynamicMediumThe argument is computed, but no request data was seen. Check where the value comes from.The argument is not a fixed value, and no request data was found in or behind it.
LowLowThe argument is a fixed value.Only when fixed values are included. Normal scans skip them, so this badge does not appear.

How request data is recognised

The argument is checked for the usual ways each language reads a request, such as req.body, request.args, request.getParameter, $_GET, r.FormValue, params[ and Request.Query. If the argument is a variable, the 80 lines above the call are searched for where that variable was assigned. If it was assigned from request data, including destructuring such as const { id } = req.body, the finding is User input and the evidence names that line.

Where Dynamic findings appear

SQL, command, code execution and deserialization calls are dangerous even when the value only looks computed, so they are shown as both User input and Dynamic. File access, outbound requests, HTML output, redirects, LDAP and XPath calls are everywhere in normal code, so they are shown only when request data reaches them.

warning
Dynamic means the scanner could not see where the value comes from. It does not mean the call is probably safe.

Prioritising findings

The dashboard sorts findings by severity, then puts user-input findings first, then orders them by file and line. A good order to work through them:

  1. 1
    Critical with User input. Fix these first. They are very likely exploitable injections.
  2. 2
    Critical with Dynamic. Review next. Trace where the value comes from, and fix the call if a user can reach it.
  3. 3
    High with User input. Fix soon.
  4. 4
    Medium with User input. Schedule a fix.

Limitations

  • Detection is pattern-based. It does not follow values through other functions or files, so request data that reaches a call through another function shows as Dynamic, not User input.
  • It does not understand validation between where a value comes from and where it is used. A value checked against an allow-list is still reported.
  • Languages other than Python are read as text with comments and strings masked out, which is less precise.
  • A finding means a dangerous call takes a value that is not fixed. Treat it as a lead to review, not a confirmed vulnerability.