Sensei Logo Sensei Hub

Recipe - Security Misconfiguration: StrictHttpFirewall: Rule configuration: Reject URL encoded slash

Description:
Rejecting the use of a URL encoded slash is more secure
Level:
warning
Language:
  • java
Tags:
  • Spring
  • security
  • framework specific
  • Spring Security
  • web
Documentation

Disallowing a URL encoded slash ("%2F") in the URL is more secure, as they are frequently used to bypass security constraints. Spring Security by default sets setAllowUrlEncodedSlash to false.

Before
firewall.setAllowUrlEncodedSlash(true);
After
firewall.setAllowUrlEncodedSlash(false);
References
Recipe
id: scw:spring:security:stricthttpfirewall-slash
version: 10
metadata:
  name: 'Security Misconfiguration: StrictHttpFirewall: Rule configuration: Reject URL encoded slash'
  shortDescription: Rejecting the use of a URL encoded slash is more secure
  level: warning
  language: java
  enabled: true
  descriptionFile: descriptions/RejectURLEncodedSlash.html
  tags: Spring;security;framework specific;Spring Security;web
search:
  methodcall:
    args:
      1:
        type: boolean
        value:
          stringified: "true"
    name: setAllowUrlEncodedSlash
    anyOf:
    - type: org.springframework.security.web.firewall.DefaultHttpFirewall
    - type: org.springframework.security.web.firewall.StrictHttpFirewall
availableFixes:
- name: Set setAllowUrlEncodedSlash to false
  actions:
  - modifyArguments:
      rewrite:
        1: "false"