Repository navigation
feat(scanner): WAF evasion engine v1.5.0 - #13
Conversation
WafState + WafEvasion with 5 bypass strategies (DOUBLE_ENCODE, CASE_MUTATION, UNICODE_NORMALIZE, CHARSET_EBCDIC, HPP). ScanRunner Phase 1.5 auto-probes effective bypass after WAF detection. HeadersModule marks shared WafState on 403 + WAF signature. SQLi, XSS, LFI, SSTI, CmdInjection, XXE modules integrated with evasionPayload() for transparent WAF bypass during scans. 26 WAF tests (18 unit + 8 integration with mock WAF server).
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Version.java reads version.properties (expanded by Gradle processResources) and exposes get(), label(), userAgent(). Replaces all hardcoded version strings in AnarCryGui, AnarCryTui, HeadersModule, HSTSModule, RepeaterView and the anarchrypto launcher.
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 278 |
| Duplication | 96 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
Several blocking issues remain. WAF detection currently occurs after the phase that probes and launches payload scanners, so normal scans may never share a detected WAF strategy. Payload encoding can also be applied more than once, changing the intended wire representation, while some advertised strategies are not applied through the generic evasion path.
The scanner opens target-controlled URLs without centralized scope and private-network protection, creating SSRF risk. Strategy probing also treats non-blocked responses as successful without verifying an application-level signal. Missing integration and ordering tests leave these high-risk paths insufficiently validated.
About this PR
- Important scanner integrations and orchestration paths remain unverified by focused tests, and the available results do not establish production line coverage.
2 comments outside of the diff
src/main/java/gg/effront/anarcry/scanner/crypto/headers/HeadersModule.java
line 39🔴 HIGH RISK
Route requests through centralized target validation and validate both the initial URI and every redirect against scope and disallowed IP ranges.
src/main/java/gg/effront/anarcry/scanner/crypto/hsts/HSTSModule.java
line 41🔴 HIGH RISK
Validate scheme, scan scope, resolved IP ranges, and redirect destinations before connecting. Reject loopback, private, link-local, multicast, and metadata-service addresses unless explicitly allowed, using a centralized request validator.
Test suggestions
- Unit-test all five strategy implementations and strategy routing, including HPP and EBCDIC behavior
- Test WAF detection from status, headers, and response body
- Test thread-safe sharing of WafState between modules
- Test strategy probing and selection order
- Test HeadersModule marking shared WafState
- Test SQLi payload bypass through the integrated module
- Test XSS, LFI, SSTI, command-injection, and XXE integrations independently
- Test ScanRunner ordering and automatic WAF probing before scanner modules execute
- Test that transformed payloads are encoded exactly once and produce the intended double-encoding semantics
- Test version.properties expansion and runtime fallback behavior
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Test XSS, LFI, SSTI, command-injection, and XXE integrations independently
2. Test ScanRunner ordering and automatic WAF probing before scanner modules execute
3. Test that transformed payloads are encoded exactly once and produce the intended double-encoding semantics
4. Test version.properties expansion and runtime fallback behavior
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| return local; | ||
| } | ||
| String encoded = URLEncoder.encode(payload, "UTF-8"); | ||
| String encoded = URLEncoder.encode(WafEvasion.evasionPayload(ctx, payload), "UTF-8"); |
There was a problem hiding this comment.
🔴 HIGH RISK
Separate raw transformations from request-boundary encoding, or provide an explicitly encoded API and stop re-encoding its result. Add an assertion for the exact wire representation.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| // Phase 1.5: WAF detection probe | ||
| if (ctx.wafState().isWafDetected()) { | ||
| safeLog.accept( | ||
| "[*] Phase 1.5: WAF detectado (" + ctx.wafState().wafProduct() + ") -- probing bypass strategies"); | ||
| try { | ||
| WafEvasion.Strategy effective = WafEvasion.probeStrategies(ctx, HttpClientFactory.http2(), | ||
| ctx.targetUrl(), "WafProbe", safeLog); | ||
| if (effective != null) { | ||
| ctx.wafState().markEffectiveStrategy(effective); | ||
| safeLog.accept("[+] WAF bypass: usando " + effective + " para modulos de payload"); | ||
| } | ||
| } catch (Exception e) { | ||
| safeLog.accept("[!] WAF probe falhou: " + e.getMessage()); | ||
| } | ||
| } |
There was a problem hiding this comment.
🔴 HIGH RISK
WAF detection runs too late: HeadersModule executes as a scanner after Phase 1.5, so the state is unset when probing and payload scanners begin. Move detection into reconnaissance or perform a dedicated preliminary request before Phase 1.5.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| HttpResponse<String> resp = Http.send(ctx, hc, req, HttpResponse.BodyHandlers.ofString(), moduleId); | ||
| String server = resp.headers().firstValue("Server").orElse(""); | ||
| String body = resp.body() != null ? resp.body() : ""; | ||
| if (!isWafBlocked(resp.statusCode(), server, body)) { |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Require a baseline comparison and an application-level success signal, such as canary reflection or an expected response, before marking a strategy effective; otherwise continue probing or leave it unset.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| public static String evasionPayload(ScanContext ctx, String payload) { | ||
| if (!ctx.wafState().isWafDetected()) { | ||
| return payload; | ||
| } | ||
| Strategy s = ctx.wafState().effectiveStrategy(); | ||
| if (s == null) { | ||
| return payload; | ||
| } | ||
| return applyGetStrategy(s, payload); |
There was a problem hiding this comment.
🟡 MEDIUM RISK
The generic evasion path does not apply HPP or EBCDIC transformations, so the advertised strategy support is incomplete across integrated modules. Add strategy-specific request construction or constrain the integration behavior explicitly.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
- Fix doubleEncode triple-encoding bug: return single-encoded so caller's URLEncoder.encode completes the double on wire - Skip HPP/EBCDIC as effective strategy in probeStrategies (not GET-compatible) - Add JS challenge detection (isJsChallenge, detectChallengeType) - Skip time-based blind phase in CmdInjection and SQLi when BrowserTransport is active (latency makes timing unreliable) - Group report Details section by module+title to collapse duplicate findings that differ only by endpoint - PQC positive findings (TLS 1.3/X25519MLKEM768 supported) now correctly report as INFO instead of LOW - Add BrowserTransport, ChallengeSolver, StealthHttpClient - Add CommandInjectionModuleTest (9 tests), SQLi BT tests (2), WafEvasion JS challenge tests (19), doubleEncode wire-form test
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Add BrowserTransport.stub(targetHost) factory method for tests, replacing reflection-based constructor access flagged by Codacy.
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Semgrep Static Analysis
✅ No issues found. |
SpotBugs + FindSecBugs
✅ No high-priority issues. |
Security Scan Summary
✅ All security checks passed! |
Summary
WafState+WafEvasioninscanner/util/with 5 bypass strategies -- DOUBLE_ENCODE, CASE_MUTATION, UNICODE_NORMALIZE, CHARSET_EBCDIC, HPPWafStateevasionPayload()transparently when WAF detectedWafStateon HTTP 403 + WAF signature (Cloudflare, Akamai, Incapsula, etc.)sendXml()usescharset=ibm500encoding when CHARSET_EBCDIC is the effective strategyTest plan
WafEvasionTest) -- strategy implementations, WAF detection, request builders, evasionPayload integrationWafHarnessTest) -- mock WAF server, probe strategies, full evasion flow, HeadersModule WAF detection, SQLi bypass with evasion