Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 37 ยท Security Hotspots

Reviewing Security Hotspots: A Step-by-Step Workflow

A practical workflow for reviewing SonarQube security hotspots: open the risk description, decide Safe, Fixed or Acknowledged, comment, assign, and handle permissions and priorities.

A hotspot does nothing until somebody reviews it. The review is short when you know what to look at: read why the code is sensitive, decide whether your usage is dangerous, and record the decision. This lesson walks through the review page, the questions to ask, and a worked set of examples.

As before, SonarQube itself cannot run on this site, so the menus are described in words and the TryIts are stand-ins that teach the decision logic.

Where hotspots live

Open a project and choose the Security Hotspots tab. The list can be filtered by branch or pull request, status, review priority, category (such as "Weak Cryptography" or "Insecure Configuration"), and by whether the code is new. On the left are the hotspots; on the right is the selected one with its code.

Each hotspot has four tabs in the detail pane:

  1. Where is the risk? The line and a short explanation of what is sensitive.
  2. What's the risk? What an attacker could do if the usage is unsafe.
  3. Assess the risk. A checklist of "Ask yourself whether..." questions. Answer them honestly for your code.
  4. How can I fix it? Compliant and non-compliant examples for your language.

The Review button opens a menu for the status and a comment box. The status choices are Acknowledged, Fixed, Safe (and back to To Review if you were wrong).

The five-minute review

Use this routine for each hotspot.

  1. Read the line in context. Open the whole function, not only the highlighted statement.
  2. Read "Assess the risk". The questions are written so that one "yes" means danger. For a Math.random() hotspot: "Is the value used for a security purpose such as a token, key or password?"
  3. Decide.
    • Real danger and you will repair it now: change the code, rescan, and the hotspot closes as Fixed. You can also set Fixed yourself if you have already fixed it locally and the scan has not run.
    • Real danger, but accepted for a while: Acknowledged with a comment and a ticket link.
    • No danger in this usage: Safe with a comment that says why.
  4. Comment. A reviewer a year from now should understand the decision without asking you.
  5. Move on. Do not leave the status as To Review.

Write the Safe comment as a short argument: "Used only to pick a random banner. No secret or identity derives from it." If you cannot write that sentence, the status is not Safe.

Worked examples

Code Question Decision
token = Math.random().toString(36) in a password reset flow Does it protect an account? Yes Fix: use a cryptographically secure generator
shuffle(playlist, Math.random) Is any secret derived? No Safe
createHash("sha1") to compute an ETag Is it a password or signature? No Safe
createHash("md5") on passwords Yes Fix: use a password hashing function
fetch("http://internal.corp/api") carrying customer data Is data protected in transit? No Fix or Acknowledged with a ticket
Access-Control-Allow-Origin: * on a public read-only API Are credentials or private data exposed? No Safe

Review priority

Each rule has a built-in review priority: High (a mistake leads to critical damage, for example authentication or injection related), Medium or Low. Sort by priority so the riskiest hotspots are reviewed first. The priority describes the rule, not your code; a High hotspot can still be Safe.

Who can review

Changing a hotspot's status needs the project permission Administer Security Hotspots (in the project's Permissions page). Anyone who can see the project can read hotspots and comment; in the usual setup security-minded developers or champions hold the permission. Hotspots can also be assigned to a person so the work has an owner. In SonarQube for IDE (the IDE plugin, formerly SonarLint) in connected mode, hotspots appear in the editor for the same project so they can be reviewed before the pull request.

Stand-in: a hotspot review queue

The block below keeps a tiny queue sorted by priority, applies reviews with a mandatory comment, and prints what remains. It imitates the rule "a decision needs a reason".

JS Stand-in: review queue with mandatory comments

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

No output.

Reviewing across branches and pull requests

Hotspots are tracked per branch. When a pull request is analysed (a Developer Edition or higher feature), the PR page lists hotspots introduced by that PR, and the quality gate needs them reviewed. After the PR is merged, SonarQube carries the review decisions over to the main branch when it matches the same code, so you do not review twice. If the code moved or changed enough for the match to fail, the hotspot returns as To Review.

Review hygiene for a team

  • Agree on who holds the Administer Security Hotspots permission.
  • Review new hotspots in the pull request, while the author still remembers the code.
  • Once a quarter, filter by "all code" and burn down old To Review items.
  • Keep the comment standard: what the code does, why it is safe or what will fix it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A hotspot marks code that hashes an ETag with SHA-1. Nothing secret is involved. Which status fits?

    The usage is not security relevant, so Safe with a comment explaining why is right.
  2. 2. What permission lets a user change a hotspot status?

    Project permission Administer Security Hotspots controls who can review.
  3. 3. What does the review priority describe?

    Priority belongs to the rule: it estimates the damage if the sensitive code turns out to be unsafe.
  4. 4. Which status means a real risk exists and has been accepted for now?

    Acknowledged records a known risk; adding a ticket link in the comment keeps it visible.

Summary

  • Review each hotspot in context: read the risk, answer the "Assess the risk" questions, then choose a status.
  • Safe means this usage is harmless; Fixed means the code changed; Acknowledged means a known risk.
  • Always leave a comment that explains the decision.
  • Reviewing is a permissioned action and is best done inside the pull request.

Next: OWASP, CWE and security reports