Recipe Name:
Security Misconfiguration: StrictHttpFirewall: Rule configuration: Reject (URL encoded) backslash
Description:
Rejecting the use of a (URL encoded) backslash is more secure
Level:
warning
Language:
  • java
Tags:
  • Spring
  • security
  • framework specific
  • Spring Security
  • web
Documentation

Disallowing a backslash or a URL encoded backslash ("%5C") in the URL is more secure, as they are frequently used in exploits. Spring Security by default sets StrictHttpFirewall#setAllowBackSlash to false.

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