Skip to content

SSRF Operator Configuration#434

Merged
Anilm3 merged 4 commits into
masterfrom
anilm3/ssrf-configuration
Jul 30, 2025
Merged

SSRF Operator Configuration#434
Anilm3 merged 4 commits into
masterfrom
anilm3/ssrf-configuration

Conversation

@Anilm3

@Anilm3 Anilm3 commented Jul 25, 2025

Copy link
Copy Markdown
Collaborator

This PR introduces SSRF configuration as defined in RFC-1049, allowing the security team to better tweak the SSRF heuristic.

The default configuration of the SSRF rule can be seen below:

  options:
    authority-inspection: true
    path-inspection: false
    query-inspection: false
    forbid-full-url-injection: false
    enforce-policy-without-injection: false
  policy:
    allowed-schemes:
      - https
      - http
      - ftps
      - ftp
    forbidden-domains:
      - metadata.google
      - burpcollaborator.net
      - .local
      - .internal
      - ram.aliyuncs.com
      - ifconfig.pro
      - localhost
      - localtest.me
    forbidden-ips:
      - 169.254.0.0/16
      - 127.0.0.1/32
      - 10.0.0.0/8
      - 172.16.0.0/12
      - 192.168.0.0/16
      - 100.64.0.0/10
      - ::1/128
      - fc00::/7
      - fe80::/10
      - 2001:db8:1234:1a00::/56

The version of the operator has also been increased to v3.

Related Jiras: APPSEC-58463

@github-actions

github-actions Bot commented Jul 25, 2025

Copy link
Copy Markdown

Artifact Size Comparison 📦

Artifact Previous Release This PR Difference
darwin-arm64::libddwaf.a 83315344 83667752 0.00%
darwin-arm64::libddwaf.a.stripped 4352184 4377936 0.00%
darwin-arm64::libddwaf.dylib 1919536 1920912 0.00%
darwin-universal::libddwaf.a 167911160 168637664 0.00%
darwin-universal::libddwaf.a.stripped 9268592 9325496 0.00%
darwin-universal::libddwaf.dylib 4033072 4034448 0.00%
darwin-x86_64::libddwaf.a 84595768 84969864 0.00%
darwin-x86_64::libddwaf.a.stripped 4916360 4947512 0.00%
darwin-x86_64::libddwaf.dylib 2091048 2092400 0.00%
linux-aarch64::libddwaf.a 68876962 69851954 0.01%
linux-aarch64::libddwaf.a.stripped 11720766 11470590 -0.02%
linux-aarch64::libddwaf.so 2429048 2426848 0.00%
linux-armv7::libddwaf.a 60213732 61651782 0.02%
linux-armv7::libddwaf.a.stripped 10612116 10473830 -0.01%
linux-armv7::libddwaf.so 2103320 2105168 0.00%
linux-i386::libddwaf.a 58414994 59925488 0.02%
linux-i386::libddwaf.a.stripped 9009642 9055364 0.00%
linux-i386::libddwaf.so 2302460 2340984 0.01%
linux-x86_64::libddwaf.a 68977050 70307522 0.01%
linux-x86_64::libddwaf.a.stripped 11389686 11289686 0.00%
linux-x86_64::libddwaf.so 2602216 2613784 0.00%
windows-win32::ddwaf.dll 3292160 3299840 0.00%
windows-win32::ddwaf.lib 11684 11922 0.02%
windows-win32::ddwaf_static.lib 46934870 47190332 0.00%
windows-x64::ddwaf.dll 4021248 4032000 0.00%
windows-x64::ddwaf.lib 11464 11698 0.02%
windows-x64::ddwaf_static.lib 54410908 54763028 0.00%
windows-x86_64::libddwaf.a 6204034 6245176 0.00%
windows-x86_64::libddwaf.dll 18785618 18795354 0.00%
windows-x86_64::libddwaf.dll.a 31292 31948 0.02%

@pr-commenter

pr-commenter Bot commented Jul 25, 2025

Copy link
Copy Markdown

Benchmarks clang

Benchmark execution time: 2025-07-30 19:12:18

Comparing candidate commit 2f60fc1 in PR branch anilm3/ssrf-configuration with baseline commit 6a7d4b4 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@pr-commenter

pr-commenter Bot commented Jul 25, 2025

Copy link
Copy Markdown

Benchmarks gcc

Benchmark execution time: 2025-07-30 19:12:51

Comparing candidate commit 2f60fc1 in PR branch anilm3/ssrf-configuration with baseline commit 6a7d4b4 in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics.

scenario:global-benchmark.random.gcc

  • 🟩 execution_time [-8.793ms; -8.751ms] or [-3.080%; -3.066%]

@pr-commenter

pr-commenter Bot commented Jul 25, 2025

Copy link
Copy Markdown

Benchmarks clang-pgo

Benchmark execution time: 2025-07-29 09:38:06

Comparing candidate commit 6a7d4b4 in PR branch anilm3/ssrf-configuration with baseline commit 6a7d4b4 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch from 6aa0f27 to 1605009 Compare July 28, 2025 09:35
@codecov-commenter

codecov-commenter commented Jul 28, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.52632% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.30%. Comparing base (6a7d4b4) to head (2f60fc1).
⚠️ Report is 41 commits behind head on master.

Files with missing lines Patch % Lines
src/configuration/common/expression_parser.cpp 82.75% 4 Missing and 1 partial ⚠️
src/condition/ssrf_detector.cpp 92.72% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #434      +/-   ##
==========================================
- Coverage   85.32%   85.30%   -0.02%     
==========================================
  Files         175      176       +1     
  Lines        8953     9031      +78     
  Branches     3926     3968      +42     
==========================================
+ Hits         7639     7704      +65     
- Misses        506      512       +6     
- Partials      808      815       +7     
Flag Coverage Δ
waf_test 85.30% <90.52%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch from 1605009 to 0f9db1b Compare July 28, 2025 10:59
Comment thread src/configuration/common/expression_parser.cpp Outdated
@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch 2 times, most recently from e25f7f9 to 0748db7 Compare July 28, 2025 14:10
@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch from 0748db7 to c5289a3 Compare July 28, 2025 14:20
@Anilm3
Anilm3 marked this pull request as ready for review July 28, 2025 14:20
@Anilm3
Anilm3 requested a review from a team as a code owner July 28, 2025 14:20
@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch from 86a6c4e to 758fe7f Compare July 28, 2025 15:06
@Anilm3
Anilm3 requested a review from Taiki-San July 28, 2025 15:06
@Anilm3
Anilm3 requested review from cataphract and Copilot July 28, 2025 16:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements SSRF (Server-Side Request Forgery) configuration capabilities as defined in RFC-1049, allowing security teams to customize SSRF detection heuristics through configurable options and policies. The implementation provides granular control over authority, path, and query inspection, along with customizable allowed schemes, forbidden domains, and forbidden IP ranges.

Key changes:

  • Updated SSRF detector operator to version 3 with configurable options and policies
  • Added comprehensive test coverage for all configuration scenarios
  • Introduced flexible enforcement modes including policy-only enforcement and full URL injection detection

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
validator/tests/rules/structured/ssrf-config/ruleset.yaml Defines five SSRF detection rules with different configuration options for testing
validator/tests/rules/structured/ssrf-config/*.yaml Test cases covering various SSRF detection scenarios with different configurations
tests/unit/condition/ssrf_detector_test.cpp Unit tests for SSRF detector with configurable options and policies
src/configuration/common/expression_parser.cpp Template specialization for parsing SSRF detector configuration from YAML
src/condition/ssrf_detector.hpp Header updates adding configuration options, policies, and version bump
src/condition/ssrf_detector.cpp Core implementation of configurable SSRF detection logic
Comments suppressed due to low confidence (2)

src/condition/ssrf_detector.hpp:37

  • The variable name default_forbidden_ips suggests it contains IP addresses, but it actually contains IP ranges in CIDR notation. Consider renaming to default_forbidden_ip_ranges or default_forbidden_cidrs for clarity.
    static constexpr std::array<std::string_view, 10> default_forbidden_ips{"169.254.0.0/16",

src/condition/ssrf_detector.cpp:173

  • The variable name forbidden_domain is misleading as it can hold any of the forbidden domains, not a specific one. Consider renaming to matched_forbidden_domain to clarify its purpose.
    std::string_view forbidden_domain = {};

Comment thread tests/unit/condition/ssrf_detector_test.cpp
Comment thread src/condition/ssrf_detector.cpp
@Anilm3
Anilm3 force-pushed the anilm3/ssrf-configuration branch from 758fe7f to ea5e46b Compare July 28, 2025 16:43
Comment thread src/condition/ssrf_detector.cpp Outdated
Comment thread src/condition/ssrf_detector.cpp
@Anilm3
Anilm3 enabled auto-merge (squash) July 30, 2025 18:50
@Anilm3
Anilm3 merged commit 7fe72a0 into master Jul 30, 2025
55 of 56 checks passed
@Anilm3
Anilm3 deleted the anilm3/ssrf-configuration branch July 30, 2025 19:16
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.

5 participants