Add Rails 8 vulnerabilities aligned with OWASP Top 10 2025
This commit adds comprehensive coverage of OWASP Top 10 2025 categories, implementing both ReDoS (A05:2025) and Software Supply Chain (A03:2025) vulnerabilities for educational purposes. ## New Vulnerabilities Added ### A05:2025 - Injection (ReDoS) - Implemented three ReDoS endpoints in TutorialsController: - POST /tutorials/redos_email - Vulnerable email regex with nested quantifiers - POST /tutorials/redos_username - Classic (a+)+ pattern - POST /tutorials/redos_email_safe - Secure version using URI::MailTo::EMAIL_REGEXP - Added Regexp.timeout = 1.0 configuration (Rails 8 protection) - All endpoints include timing and error handling demonstrations ### A03:2025 - Software Supply Chain Failures - Demonstrated missing SRI on CDN assets in application.html.erb - Added educational endpoints: - GET /tutorials/supply_chain - Comprehensive supply chain vulnerabilities overview - GET /tutorials/check_dependencies - Dependency scanning simulation - Covers: Missing SRI, outdated dependencies, no SBOM, insecure gem sources ## Files Changed ### New Files - config/initializers/regexp_timeout.rb: Enables Rails 8 ReDoS protection - spec/controllers/tutorials_controller_spec.rb: 23 passing tests for all endpoints ### Modified Files - app/controllers/tutorials_controller.rb: Added 5 new educational endpoints - app/views/layouts/application.html.erb: Added CDN assets WITHOUT SRI (intentional vuln) - config/routes.rb: Added routes for ReDoS and supply chain endpoints ## Test Coverage - 23 RSpec tests covering both ReDoS and A03 vulnerabilities - Tests validate vulnerability behavior, error handling, and educational content - All tests passing ## Educational Value - Demonstrates OWASP 2025 categories A03 and A05 - Shows both vulnerable and secure implementations - Includes real-world CVE examples (British Airways, Magecart) - Provides mitigation guidance and tool recommendations This completes 100% coverage of OWASP Top 10 2025 categories in RailsGoat Rails 8. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Rails 8 ReDoS Protection
|
||||
# Enable automatic timeout for regular expressions to prevent ReDoS attacks
|
||||
# Default: 1 second timeout for regex operations
|
||||
#
|
||||
# This is a Rails 8 security feature that prevents catastrophic backtracking
|
||||
# in regular expressions from hanging the application.
|
||||
#
|
||||
# See: R8-A1-ReDoS tutorial in wiki for exploitation details
|
||||
|
||||
Regexp.timeout = 1.0 # 1 second timeout
|
||||
Reference in New Issue
Block a user