Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 37 ยท Security Hotspots

Security Hotspots vs Vulnerabilities in SonarQube

Learn how SonarQube separates vulnerabilities from security hotspots, why hotspots need a human review, and how each one affects the security rating and the quality gate.

SonarQube reports two kinds of security findings, and they behave very differently. A vulnerability is code that the analyzer is confident is exploitable: an SQL query built from user input, for example. A security hotspot is code that is security-sensitive: it may be perfectly safe, or it may be a hole, and only a person who knows the context can say which.

This lesson explains the difference, shows how each kind is counted, and builds a small stand-in scanner so you can see why the two categories exist. The real SonarQube server is not available on this site, so every TryIt below is a plain JavaScript stand-in that imitates the idea, not the product.

Vulnerability: a finding you must fix

A vulnerability is raised when the rule can see a problem without needing to know your intent. Typical examples:

  • Building an SQL statement by concatenating a request parameter (injection).
  • Disabling TLS certificate validation in an HTTP client.
  • Using a cipher mode that is known to be broken for the way it is used.

Vulnerabilities are issues. They have an assignee, a severity (or an impact level in recent versions), a status and a remediation time estimate. They count toward the Security rating of the project, from A (no vulnerabilities) to E (at least one blocker vulnerability). On new code the default quality gate fails when a new vulnerability appears.

Security hotspot: a finding you must review

A hotspot is raised on code that is commonly involved in attacks but is not always wrong. Examples:

  • Using a pseudorandom number generator such as Math.random() (fine for shuffling a playlist, wrong for a password reset token).
  • Hashing with MD5 or SHA-1 (fine for a cache key, wrong for passwords).
  • Calling a URL over http:// (fine on a loopback address in a test, wrong for user data).
  • Permitting any origin in CORS configuration.
  • A string that looks like a hard-coded credential.

Hotspots are not issues. They live on their own page, the Security Hotspots tab of a project, and they are not counted in the Security rating. Instead they have a status and a review priority (High, Medium or Low), which says how bad the problem would be if the code were in fact insecure.

The four statuses:

Status Meaning
To Review Nobody has looked at it yet.
Acknowledged A real risk, accepted for now; a fix is planned or the risk is understood.
Fixed The code was changed so that the risk is gone.
Safe Reviewed, and the code is fine in its context.

The last three count as reviewed. Hotspots that stay To Review count against you in a metric called Security Hotspots Reviewed, the percentage of hotspots that have been reviewed. The built-in Sonar way quality gate requires that metric to be 100% on new code, so a pull request that adds a sensitive call cannot merge until somebody has made a decision.

The exact menu labels and the wording of the default gate change between SonarQube releases (Server 10.x, 2025.x and later). The concepts here stay the same. Always check the Quality Gates page on your own server to see the conditions in force.

Why the split exists

If SonarQube reported every Math.random() as a vulnerability, teams would drown in false positives, mark them all "won't fix" and stop trusting the tool. By saying "this needs a human" the product keeps the vulnerability list high-precision and still makes sure sensitive code is looked at once.

flowchart TD
  A["Analyzer finds sensitive code"] --> B{"Sure it is exploitable?"}
  B -- "Yes" --> C["Vulnerability (issue)"]
  B -- "Depends on context" --> D["Security hotspot"]
  C --> E["Counts in Security rating"]
  D --> F["Counts in Hotspots Reviewed %"]

Figure: vulnerabilities feed the rating; hotspots feed the review percentage.

A stand-in classifier

The block below is not SonarQube. It is a tiny rule table that mimics the split: rules marked certain become vulnerabilities, rules marked contextual become hotspots. Edit the snippets and watch the buckets change.

JS Stand-in: vulnerability or hotspot?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that the localhost call is not flagged: real rules also try to exclude cases that are obviously harmless, which keeps the hotspot count manageable.

How the numbers feed the quality gate

Suppose a pull request adds 4 hotspots. Nobody has looked at them yet, so reviewed = 0 of 4 = 0%. Two are marked Safe and one Fixed: reviewed = 3 of 4 = 75%. The gate wants 100%, so the PR is still blocked. The calculation is simple enough to try.

JS Stand-in: hotspots reviewed percentage

Press Run (or Ctrl + Enter) to see the console output here.

No output.

With no hotspots at all the metric is 100%, because there is nothing left to review.

Common mistakes

  • Marking everything Safe to turn the gate green. The status is a security decision with your name on it. Add a comment that explains why the code is safe.
  • Treating hotspots as bugs in the backlog. They are a review queue, not a to-do list; most should end in Safe.
  • Ignoring hotspots in old code. The default gate looks at new code only, but the project-wide list still shows the old ones. Plan a periodic review (see Reviewing security hotspots).
  • Expecting a hotspot to lower the Security rating. It will not; only vulnerabilities do.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about a security hotspot is correct?

    Hotspots mark sensitive code whose safety depends on context, so a person reviews them.
  2. 2. A project has 8 hotspots: 2 Safe, 1 Fixed, 1 Acknowledged and 4 To Review. What is Security Hotspots Reviewed?

    Safe, Fixed and Acknowledged all count as reviewed: 4 of 8 is 50%.
  3. 3. Which finding counts toward the Security rating?

    The Security rating is computed from vulnerabilities, not from hotspots.
  4. 4. Why does the default gate require 100% hotspots reviewed on new code?

    The condition forces a review decision for sensitive code introduced in new code.

Summary

  • A vulnerability is a confident, fixable finding that affects the Security rating.
  • A hotspot is sensitive code that needs a review; it has a status and a review priority.
  • To Review is the only status that is not "reviewed"; the gate wants 100% reviewed on new code.
  • The TryIts here are stand-ins that teach the logic; they are not the SonarQube analyzer.

Next: Reviewing security hotspots