Skip to content

Count 404 requests with foreign extensions as attack wave scans#292

Open
bitterpanda63 wants to merge 1 commit into
mainfrom
fix/attack-wave-foreign-extension-404
Open

Count 404 requests with foreign extensions as attack wave scans#292
bitterpanda63 wants to merge 1 commit into
mainfrom
fix/attack-wave-foreign-extension-404

Conversation

@bitterpanda63

@bitterpanda63 bitterpanda63 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Ports Count 404 requests with foreign extensions as scans firewall-node#1041 to Ruby
  • Requests to foreign-platform extensions (php, php3, php4, php5, phtml, java, jsp, jspx) are only counted as scan hits when the HTTP response status is 404
  • A 200 response may mean the Ruby app is proxying to a PHP/Java backend, so those requests should not be flagged as scanning behaviour

Changes

  • lib/aikido/zen/attack_wave/helpers.rb: Added FOREIGN_EXTENSIONS set; updated suspicious_path? and web_scanner? to accept and use status_code
  • lib/aikido/zen/attack_wave.rb: Updated Detector#attack_wave? to accept and forward status_code
  • lib/aikido/zen/middleware/attack_wave_protector.rb: Extracts status_code from the Rack response and passes it through protectattack_wave? → detector
  • test/aikido/zen/attack_wave_test.rb: Added HelpersTest covering the 404-only and always-suspicious behaviours

Test plan

  • suspicious_path?("/admin.php", 404) → true
  • suspicious_path?("/admin.php", 200) → false
  • suspicious_path?("/app.jsp", 404) → true
  • Always-suspicious extensions (.sql, .db, .bak) still return true regardless of status
  • Suspicious file names (e.g. wp-config.php) still return true regardless of status
  • Run bundle exec rake test and confirm no regressions

🤖 Generated with Claude Code

Summary by Aikido

Security Issues: 0 🔍 Quality Issues: 1 Resolved Issues: 0

⚡ Enhancements

  • Flagged foreign extensions as scans only on 404; updated detector and tests

More info

Ports AikidoSec/firewall-node#1041 to Ruby. Requests to foreign-platform
extensions (php, java, jsp, etc.) are only counted as scan hits when the
response status is 404 — a 200 response may indicate the Ruby app is
proxying to a PHP/Java backend rather than serving the file itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

return true if SUSPICIOUS_FILE_EXTENSIONS.include?(file_extension)

return true if FOREIGN_EXTENSIONS.include?(file_extension) && status_code == 404

@aikido-pr-checks aikido-pr-checks Bot Jun 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid a chained condition in the nested file_name branch. Split FOREIGN_EXTENSIONS check and status_code check into clearer guard/early-return steps to reduce nesting and improve readability.

Suggested change
return true if FOREIGN_EXTENSIONS.include?(file_extension) && status_code == 404
if FOREIGN_EXTENSIONS.include?(file_extension)
return true if status_code == 404
end
Details

✨ AI Reasoning
​The change inserted a new return that combines two checks with && inside the nested file_name branch, increasing branching complexity in a block that already contains multiple return-true checks. Separating these into explicit guard checks (e.g., check file_extension membership first, then check status_code) or inverting the condition into an early-return/guard would flatten nesting and improve readability and maintainability.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant