Sensei Logo Sensei Hub

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

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

Disallowing a URL encoded percent ("%25") in the URL is more secure, as they are frequently used to bypass security constraints. Spring Security by default sets StrictHttpFirewall#setAllowUrlEncodedPercent to false.

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