Skip to content

Enhance vulnerability descriptions with Source, Solution, and Reference (Fixes #89) - #735

Open
MixhizoR wants to merge 4 commits into
SasanLabs:masterfrom
MixhizoR:refactor/issue-89-vulnerability-description-schema
Open

Enhance vulnerability descriptions with Source, Solution, and Reference (Fixes #89)#735
MixhizoR wants to merge 4 commits into
SasanLabs:masterfrom
MixhizoR:refactor/issue-89-vulnerability-description-schema

Conversation

@MixhizoR

@MixhizoR MixhizoR commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR addresses issue #89 to improve vulnerability descriptions. Previously, descriptions were a single block of text that mixed the location of the vulnerable value with the explanation. Following the approach used by ZAP, this PR separates the Source, Solution, and Reference into distinct fields.

As noted in the issue, this was found while writing JWT Vulnerabilities, so this PR focuses on completely revamping the JWT vulnerability levels while providing the framework for other vulnerability classes to adopt later.

Key Changes

  • Backend: Added source(), solution(), and reference() to the @AttackVector annotation. Refactored AttackVectorResponseBean to include the new fields with a Builder pattern.
  • Content: Updated all 16 JWT vulnerability levels in JWTVulnerability.java with proper locations, actionable solutions, and reference links.
  • Security & UI:
    • Introduced an escapeHtml() helper in vulnerableApp.js to sanitize curlPayload, source, and solution before injecting them into innerHTML. Trusted description HTML is preserved.
    • Safely wrapped Reference URLs in clickable <a> tags with escapeHtml().
    • Fixed reverse tabnabbing globally by adding rel="noopener noreferrer" to target="_blank" links.
    • Fixed several broken 404 reference URLs.
  • Tests: Added unit tests for EndPointsInformationProvider.getMetaInformation().

Note to Reviewers

I didn't find any more links or articles for the references; any feedback or review is appreciated.

Also, while working on JWTVulnerability.java, I noticed that Levels 11 and 12 are missing entirely (the code jumps from Level 10 to Level 13, with a commented-out block for 11). I left this untouched as it is out of scope for this issue, but it might be worth tracking in a separate issue if those levels are meant to exist.

Closes #89

Summary by CodeRabbit

  • New Features

    • Added source, solution, and reference information to vulnerability details.
    • Attack-vector help now displays localized remediation guidance and supporting references.
    • Added reference links for JWT and other security vulnerabilities.
  • Bug Fixes

    • Improved handling of unavailable or blank metadata.
    • Secured dynamically rendered help content against unsafe HTML.
    • Updated external links for safer opening and corrected outdated security references.
  • Tests

    • Added coverage for metadata availability, validation, and message resolution.

…eference

Currently, vulnerability descriptions are a single block of text and do not
separate where the vulnerable value was found (e.g., Cookie, URL) from the
actual description. This implements a ZAP-style approach by introducing
Source, Solution, and Reference fields for Attack Vectors.

Changes:
- Added `source`, `solution`, and `reference` to the `@AttackVector`
  annotation and `AttackVectorResponseBean` (with Builder pattern).
- Implemented `getMetaInformation` in `EndPointsInformationProvider` to
  resolve i18n keys while gracefully handling `NOT_APPLICABLE` defaults.
- Updated all 16 JWT vulnerability levels in `JWTVulnerability.java` to
  utilize the new fields with proper, actionable content.
- Updated frontend (`vulnerableApp.js`) to render the new fields and
  implemented `escapeHtml` to prevent XSS via innerHTML injection.
- Fixed reverse tabnabbing globally by adding `rel="noopener noreferrer"`
  to all `target="_blank"` links in `messages.properties`.
- Aligned mock JSON (`mockAllEndPointJson.json`) with resolved backend formats.
- Added unit tests for `EndPointsInformationProvider.getMetaInformation()`.

Closes SasanLabs#89
Resolves SasanLabs#89

Previously, vulnerability descriptions mixed the location of the vulnerable value with the explanation. Following a ZAP-style approach, this separates the Source, Solution, and Reference into distinct fields.

Changes:
- Added `source`, `solution`, and `reference` fields to `@AttackVector` and `AttackVectorResponseBean`.
- Updated all JWT vulnerability levels to utilize the new fields with actionable content.
- Added `getMetaInformation` to resolve i18n keys gracefully.
- Fixed reverse tabnabbing globally by adding `rel="noopener noreferrer"` to `target="_blank"` links.
- Fixed broken 404 reference URLs (OWASP, IETF, CVE).
- Updated frontend to render the new fields and safely wrap reference URLs in clickable links without introducing XSS.
- Added unit tests for `EndPointsInformationProvider.getMetaInformation()`.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Attack-vector responses now include source, solution, and reference metadata. JWT annotations and localization catalogs provide the metadata. The endpoint provider resolves and exposes it. Browser rendering escapes dynamic values and adds secure external links.

Changes

Attack-vector metadata

Layer / File(s) Summary
Response and annotation contracts
src/main/java/org/sasanlabs/beans/AttackVectorResponseBean.java, src/main/java/org/sasanlabs/internal/utility/annotations/AttackVector.java
The response bean adds immutable metadata fields, constructors, getters, and a fluent builder. The annotation adds metadata members with NOT_APPLICABLE defaults.
JWT metadata catalog
src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java, src/main/resources/i18n/messages*.properties, src/main/resources/static/mockAllEndPointJson.json
JWT attack vectors now define source, solution, and reference keys. Message catalogs add localized metadata and update external links. Mock responses include the new fields.
Endpoint metadata resolution
src/main/java/org/sasanlabs/service/impl/EndPointsInformationProvider.java, src/test/java/org/sasanlabs/service/impl/EndPointsInformationProviderTest.java
The provider resolves localized metadata, suppresses unavailable values, includes metadata in responses, and appends available values to facade hints. Tests cover invalid inputs and successful resolution.
Browser metadata rendering
src/main/resources/static/vulnerableApp.js
Dynamic payload and metadata values are HTML-escaped. Optional source and solution sections are rendered. References use secure external-link attributes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AttackVector
  participant EndPointsInformationProvider
  participant MessageBundle
  participant Browser
  AttackVector->>EndPointsInformationProvider: provide metadata keys
  EndPointsInformationProvider->>MessageBundle: resolve localized source, solution, and reference
  MessageBundle-->>EndPointsInformationProvider: return localized metadata
  EndPointsInformationProvider-->>Browser: return enriched attack-vector response
  Browser->>Browser: escape dynamic metadata and render help
Loading

Suggested reviewers: vianbas

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: adding separate Source, Solution, and Reference vulnerability metadata for issue #89.
Linked Issues check ✅ Passed The changes implement issue #89 by separating vulnerability metadata and applying the ZAP-style structure to JWT vulnerabilities.
Out of Scope Changes check ✅ Passed The security fixes, URL updates, frontend escaping, and tests directly support the metadata enhancement and issue requirements.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.89655% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.04%. Comparing base (e8c5f69) to head (3dcf2c9).
⚠️ Report is 43 commits behind head on master.

Files with missing lines Patch % Lines
.../org/sasanlabs/beans/AttackVectorResponseBean.java 0.00% 37 Missing ⚠️
...abs/service/impl/EndPointsInformationProvider.java 19.04% 17 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #735      +/-   ##
============================================
- Coverage     55.37%   55.04%   -0.34%     
- Complexity      760      771      +11     
============================================
  Files           105      105              
  Lines          4229     4284      +55     
  Branches        452      456       +4     
============================================
+ Hits           2342     2358      +16     
- Misses         1683     1722      +39     
  Partials        204      204              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java`:
- Around line 433-436: Update the source metadata in JWTVulnerability.java at
lines 433-436 to use JWT_SOURCE_HEADER because the endpoint reads
HttpHeaders.AUTHORIZATION; update the source metadata at lines 723-728 to use
JWT_SOURCE_COOKIE because that endpoint reads the cookie header.

In `@src/main/resources/i18n/messages_en_US.properties`:
- Line 60: Fix the RFC 2616 anchor in the messages resource by moving the
target="_blank" and rel="noopener noreferrer" attributes inside the opening <a>
tag, preserving the existing URL and link text.

In `@src/main/resources/static/mockAllEndPointJson.json`:
- Around line 20-23: Update the Reference field for all eight mock attack
vectors in the JSON fixture to contain only the URL, removing descriptive OWASP
text and separators while preserving each link’s destination.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d9652535-d158-4552-8272-f78b05ca4f1a

📥 Commits

Reviewing files that changed from the base of the PR and between fed2ee1 and 3dcf2c9.

📒 Files selected for processing (9)
  • src/main/java/org/sasanlabs/beans/AttackVectorResponseBean.java
  • src/main/java/org/sasanlabs/internal/utility/annotations/AttackVector.java
  • src/main/java/org/sasanlabs/service/impl/EndPointsInformationProvider.java
  • src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java
  • src/main/resources/i18n/messages.properties
  • src/main/resources/i18n/messages_en_US.properties
  • src/main/resources/static/mockAllEndPointJson.json
  • src/main/resources/static/vulnerableApp.js
  • src/test/java/org/sasanlabs/service/impl/EndPointsInformationProviderTest.java

Comment on lines +433 to +436
description = "COOKIE_CONTAINING_JWT_TOKEN_SECURITY_ATTRIBUTES_MISSING",
source = "JWT_SOURCE_COOKIE",
solution = "COOKIE_CONTAINING_JWT_TOKEN_SECURITY_ATTRIBUTES_MISSING_SOLUTION",
reference = "COOKIE_CONTAINING_JWT_TOKEN_SECURITY_ATTRIBUTES_MISSING_REFERENCE")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align source metadata with the request location.

  • src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java#L433-L436: Use JWT_SOURCE_HEADER. The endpoint reads HttpHeaders.AUTHORIZATION.
  • src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java#L723-L728: Use JWT_SOURCE_COOKIE. The endpoint reads the cookie header.
📍 Affects 1 file
  • src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java#L433-L436 (this comment)
  • src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java#L723-L728
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/sasanlabs/service/vulnerability/jwt/JWTVulnerability.java`
around lines 433 - 436, Update the source metadata in JWTVulnerability.java at
lines 433-436 to use JWT_SOURCE_HEADER because the endpoint reads
HttpHeaders.AUTHORIZATION; update the source metadata at lines 723-728 to use
JWT_SOURCE_COOKIE because that endpoint reads the cookie header.

The ability to use an authentic application URL, targeting the correct domain and with a valid SSL certificate (if SSL is used), lends credibility to \
the phishing attack because many users, even if they verify these features, will not notice the subsequent redirection to a different domain. \
<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1" target="_blank"</a> defines a variety \
<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1" target="_blank" rel="noopener noreferrer"</a> defines a variety \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the malformed RFC 2616 anchor.

Line 60 closes the opening <a> tag before target and rel. The reference opens in the current tab, and noopener noreferrer is not applied.

Proposed fix
-<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1" target="_blank" rel="noopener noreferrer"</a> defines a variety \
+<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html" target="_blank" rel="noopener noreferrer">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1"</a> defines a variety \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1" target="_blank" rel="noopener noreferrer"</a> defines a variety \
<br/><br/> <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html" target="_blank" rel="noopener noreferrer">RFC 2616 - "Hypertext Transfer Protocol - HTTP/1.1"</a> defines a variety \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/i18n/messages_en_US.properties` at line 60, Fix the RFC
2616 anchor in the messages resource by moving the target="_blank" and
rel="noopener noreferrer" attributes inside the opening <a> tag, preserving the
existing URL and link text.

Comment on lines +20 to +23
"Description": "Mock attack vector for the Show Help (Scanner) view.",
"Source": "URL (query parameter)",
"Solution": "Validate the username server side before authenticating the session.",
"Reference": "OWASP A01 Broken Access Control - https://owasp.org/Top10/A01_2021-Broken_Access_Control/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Store a URL in each Reference field.

The browser uses Reference as the anchor href. Values such as OWASP A01 Broken Access Control - https://... are relative URLs, so every mock reference link is broken. Keep only the URL in this field.

Proposed fix
- "Reference": "OWASP A01 Broken Access Control - https://owasp.org/Top10/A01_2021-Broken_Access_Control/"
+ "Reference": "https://owasp.org/Top10/A01_2021-Broken_Access_Control/"

Apply this change to all eight mock attack vectors.

Also applies to: 64-67, 85-88, 106-109, 127-130, 148-151, 169-172, 190-193

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/static/mockAllEndPointJson.json` around lines 20 - 23,
Update the Reference field for all eight mock attack vectors in the JSON fixture
to contain only the URL, removing descriptive OWASP text and separators while
preserving each link’s destination.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has had no activity for 30 days, so it's been marked stale. If you're still working on it, push a commit or leave a comment and this label will clear. Otherwise it'll close automatically in 60 days — no hard feelings, and you (or anyone else) are welcome to reopen or resubmit against current main whenever you're ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vulnerability descriptions are not proper

2 participants