Skip to content

feat: expose protocol, CWE and WASC IDs in the DAST ground truth (SasanLabs/VulnerableApp#856) - #36

Open
officialasishkumar wants to merge 2 commits into
SasanLabs:mainfrom
officialasishkumar:feat/856-dast-cwe-wasc-ids
Open

officialasishkumar wants to merge 2 commits into
SasanLabs:mainfrom
officialasishkumar:feat/856-dast-cwe-wasc-ids

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Dec 5, 2026 •

Copy link
Copy Markdown

Description

/VulnerableApp-php/scanner/dast rows now follow the DAST ground-truth schema agreed in SasanLabs/VulnerableApp#854, which the Java app has served since SasanLabs/VulnerableApp#955. Each row gets protocol, cweIds and wascIds. The existing fields are unchanged.

{"url":"http://localhost:8080/VulnerableApp-php/NoSQLInjection/LEVEL_1","variant":"UNSECURE","method":"POST","protocol":"HTTP","vulnerabilityTypes":["MongoDB NoSQL Injection"],"cweIds":[943],"wascIds":[19]}
  • The names and the IDs come from one list of vulnerability types. That list is the level's hint types, or the definition's types when no hint has a CUSTOM entry, which is the fallback the names already used. vulnerabilityTypes is unchanged.
  • The stored string IDs become unique positive integers in ascending order. A value that is not a positive integer is dropped rather than guessed, so a type without a mapping gives [].
  • protocol is "HTTP" on every row, because the app has no WebSocket levels.
Rows vulnerabilityTypes cweIds wascIds
FileUpload LEVEL_1 to LEVEL_12 Unrestricted File Upload [434] []
MagicHash LEVEL_1 to LEVEL_3 Magic Hash Exploitation [704] [2]
NoSQLInjection LEVEL_1 to LEVEL_3, LEVEL_5 MongoDB NoSQL Injection [943] [19]
NoSQLInjection LEVEL_4 Insecure Credential Storage [256] [13]

These IDs let the comparator in SasanLabs/VulnerableApp#877 match PHP rows by CWE or WASC. Right now it can only match them by type name.

The PHP validation workflow has a new step that checks the live endpoint. It requires protocol HTTP and sorted, unique, positive integer ID lists on every row, and the rows above must have exactly those names and IDs. The README has a new "Scanner endpoints" section that covers both endpoints, how a row is built, and the POST/HTTP limitation.

WASC 49 on Unrestricted File Upload

The file upload types listed WASC 49, which is "Insufficient Password Recovery". VulnerableApp maps UNRESTRICTED_FILE_UPLOAD to CWE 434 with no WASC ID, because the WASC Threat Classification has no class for file uploads. If WASC 49 were published, a password recovery finding would match all 12 FileUpload rows. The first commit removes it, so those rows have "wascIds": [], and /VulnerabilityDefinitions no longer lists it either. The facade UI does not read WASC entries.

The other mappings are published unchanged. One difference from the Java app: Insecure Credential Storage uses WASC 13, while VulnerableApp's PLAINTEXT_PASSWORD_STORAGE uses WASC 15. Both are approximations, so I left it as a separate decision.

Related Issue

Closes SasanLabs/VulnerableApp#856

How Was This Tested?

I had no Docker daemon or native PHP available. Instead I ran the code on PHP 8.2, the Dockerfile's version, compiled to WebAssembly with @php-wasm/cli. The harness invokes the /VulnerableApp-php/scanner/dast route through Bootstrap and sets NoSQLInjectionSeeder::$seeded, so MongoDB is not needed.

  1. All 20 rows have the same url, variant, method and vulnerabilityTypes as on main, and the new fields match the table above.
  2. Synthetic definitions sent through the helpers covered:
    • two hints with duplicate and unsorted IDs and lower-case identifier types;
    • the values 0, -1, abc, "", CWE-79 and 1.5, which are all dropped;
    • the definition fallback, both when no hint has a CUSTOM entry and when there are no hints;
    • a type without a mapping, which gives [];
    • numeric rather than string ordering: [99, 200, 1000].
  3. The output is identical with display_errors=1 and error_reporting=-1. This matters because the Apache image has no php.ini, so a notice would end up inside the JSON. It is also identical on PHP 8.3 and 8.4. php -l passes on both changed files, and /VulnerabilityDefinitions still renders.
  4. I ran the new workflow step's script with bash -e against that output, and it passes. It fails on main's output (no new fields), and on each of these variants: an unsorted list, string IDs, a duplicate ID, a missing protocol, WASC 49 put back on FileUpload, a missing module, an ID of 0, an empty array, and a body that is not JSON.

The PHP validation workflow on this PR runs the same step against the Docker stack.

Summary by CodeRabbit

  • Bug Fixes
    • DAST scanner results now use a consistent set of vulnerability types and derive vulnerability names and CWE/WASC identifiers from that same set.
    • CWE and WASC identifiers are limited to unique positive numbers and sorted numerically. Scanner rows now report the HTTP protocol.
    • File-upload hints no longer include the WASC vulnerability type.
  • Documentation
    • Added documentation for DAST ground-truth and sitemap endpoints, including an example result and details about vulnerability types and identifiers.

The Unrestricted File Upload vulnerability types listed WASC 49 next to
CWE 434. WASC 49 is "Insufficient Password Recovery" in the WASC Threat
Classification, which has no class for unrestricted file uploads. That
is why VulnerableApp maps UNRESTRICTED_FILE_UPLOAD to CWE 434 with no
WASC ID.

The DAST ground truth is about to publish these IDs as wascIds, so with
the wrong mapping every FileUpload row would be matched by a scanner's
password recovery finding. The type now carries only the CUSTOM name
and CWE 434, the same mapping as in VulnerableApp. The definition and
every level hint use this list, so /VulnerabilityDefinitions drops the
WASC entry as well.
/scanner/dast rows only carried url, variant, method and the CUSTOM
vulnerabilityTypes names. The DAST ground-truth schema agreed in
SasanLabs/VulnerableApp#854, which the Java application already serves,
also needs protocol, cweIds and wascIds on every row. Without them the
facade's merged ground truth gives the benchmark comparator no way to
match a PHP row by CWE or WASC, because the PHP type names are not
VulnerableApp VulnerabilityType values.

Each row is now built from one list of vulnerability types: the types
of the level's hints, or the definition's types when no hint has a
CUSTOM entry, which is the fallback the names already used. From that
list:

- vulnerabilityTypes keeps the CUSTOM names exactly as before.
- cweIds and wascIds turn the stored string IDs into unique positive
  integers in ascending order. A value that is not a positive integer
  is left out instead of guessed, so an unmapped type adds nothing and
  a list can be empty.
- protocol is "HTTP", since every level is an HTTP endpoint.

The PHP validation workflow now checks the live endpoint: every row has
protocol HTTP and sorted, unique, positive integer ID lists, and the
NoSQL Injection, Insecure Credential Storage, Magic Hash and File
Upload rows have the expected names and IDs. The README documents the
endpoint, how its rows are built, and the POST/HTTP limitation.

Closes SasanLabs/VulnerableApp#856
@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The DAST scanner selects vulnerability types for each level and derives vulnerability names and CWE/WASC IDs from that list. Rows declare the HTTP protocol. The README documents the response and the PHP workflow checks its fields and values.

Changes: DAST ground-truth response

Layer / File(s) Summary
Vulnerability type selection
src/Scanner/DASTScanner.php, src/FileUploadVulnerability/FileUpload.php
The scanner uses hint types when they contain a CUSTOM type; otherwise, it uses the definition’s types. FileUpload hints no longer include WASC 49.
Row construction and response contract checks
src/Scanner/DASTScanner.php, .github/workflows/php.yml, README.md
The scanner derives custom names and unique, positive integer CWE/WASC IDs from the selected types, sorts the IDs, and sets the protocol to HTTP. The workflow checks response fields and values for four endpoints. The README documents the routes, row format, and identifier handling.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Feature

Possibly related PRs

Merge Risk: Minimal · up to 284d4

This change adds protocol and CWE/WASC identifiers to the DAST scanner rows and documents them. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the DAST ground-truth response now exposes protocol, CWE and WASC IDs. The summary confirms DASTScanner emits protocol as HTTP and CWE/WASC IDs per row, and the object…
Linked Issues check Passed [#856] Requirements are met in the reviewed head. src/Scanner/DASTScanner.php adds protocol "HTTP", cweIds and wascIds to every row. IDs come from the same list as vulnerabilityTypes: the level's hint…
Out of Scope Changes check Passed All changed areas connect to #856 or to the PR's stated scope. Changes: DASTScanner.php (new fields and ID derivation), FileUpload.php (removes WASC 49 from the file upload hint types, so the mapping …
Full details: Title check

Explanation

The title names the main change: the DAST ground-truth response now exposes protocol, CWE and WASC IDs. The summary confirms DASTScanner emits protocol as HTTP and CWE/WASC IDs per row, and the objectives match. The title also cites issue #856, which is extra detail but does not make it misleading. The title is 94 characters, which is long but still a single readable sentence.

Full details: Linked Issues check

Explanation

[#856] Requirements are met in the reviewed head. src/Scanner/DASTScanner.php adds protocol "HTTP", cweIds and wascIds to every row. IDs come from the same list as vulnerabilityTypes: the level's hint types, or the definition's types when no hint has a CUSTOM entry. getIdentifiers() keeps only positive integers (FILTER_VALIDATE_INT, min_range 1), removes duplicates, and sorts numerically. Invalid or missing mappings give []. Existing vulnerabilityTypes is unchanged. FileUpload.php drops WASC 49, which the PR explains is a mismatched mapping, so no conflicting identifier is published. Tests: .github/workflows/php.yml adds a live-endpoint contract step that checks protocol, sorted unique positive ID lists, and exact names and IDs for the listed rows. The PR also reports ad hoc WebAssembly harness runs covering edge cases. These harness runs are not committed. No PHPUnit-style unit test appears in the diff summary. The workflow step is the committed automated check. README.md adds a 'Scanner endpoints' section that documents POST/HTTP and row construction. Residual uncertainty: the summary does not show committed unit tests for the mapping logic, and the Docker-based workflow has not run.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to #856 or to the PR's stated scope. Changes: DASTScanner.php (new fields and ID derivation), FileUpload.php (removes WASC 49 from the file upload hint types, so the mapping is not published incorrectly), README.md (documents the endpoints and limitations, as #856 requires), and .github/workflows/php.yml (automated contract check). The /VulnerabilityDefinitions change follows directly from the FileUpload.php change and is disclosed in the PR. No unrelated behavior change appears in the reviewed summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 131e6e53-a206-40bc-b240-5f19495f08e1
Commits

Reviewing files that changed from the base of the PR and between 5de0b62 and 284d4d7.

Files selected for processing: 4

  • .github/workflows/php.yml
  • README.md
  • src/FileUploadVulnerability/FileUpload.php
  • src/Scanner/DASTScanner.php
Files with no reviewable changes: 1

  • src/FileUploadVulnerability/FileUpload.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VulnerableApp-PHP] Align the DAST Ground-Truth Response With the CWE/WASC Schema

1 participant