SecurityContext

weak-csp-detect: Weak Content Security Policy - Detect

Classification

  • Cwe: CWE-693
  • Not known: cvss score, cvss vector, epss score, epss percentile, cpe

Metadata

  • Max-request: 1
  • Verified: yes

Labels

  • Name: Content Security Policy - Weak CSP Configuration
  • Impact: Attackers can execute malicious scripts more easily due to weakened CSP, increasing risk of XSS attacks.
  • Remediation: Update CSP configuration to remove unsafe and overly permissive keywords and enforce stricter resource loading restrictions.
  • Vulnerability type: misconfiguration
  • Vulnerability impact: client_script_exec
  • Requirement type: none
  • Labels source: securitycontext
  • Not known: requirements, from cve

```yaml

id: weak-csp-detect

info:

name: Weak Content Security Policy - Detect

author: pussycat0x,celbahraoui

severity: info

description: |

Detected misconfigured CSP directives containing unsafe and overly permissive keywords that weakened resource loading restrictions. This configuration allowed high-risk script behaviors, resulting in reduced protection against XSS attacks.

reference:

- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors

- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src

- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/object-src

- https://content-security-policy.com/

classification:

cwe-id: CWE-693

metadata:

max-request: 1

verified: true

tags: csp,misconfig,headers,vuln

http:

- method: GET

path:

- "{{BaseURL}}"

matchers-condition: or

matchers:

- type: dsl

name: missing-script-src

dsl:

- "contains(to_lower(header), 'content-security-policy:')"

- "!contains(to_lower(header), 'script-src')"

- "!contains(to_lower(header), 'default-src')"

condition: and

- type: dsl

name: missing-object-src

dsl:

- "contains(to_lower(header), 'content-security-policy:')"

- "!contains(to_lower(header), 'object-src')"

- "!contains(to_lower(header), 'default-src')"

condition: and

- type: dsl

name: unsafe-script-src

dsl:

- "contains(to_lower(header), 'content-security-policy:')"

- "regex('(?i)script-src[^;]*(unsafe-inline|unsafe-eval|unsafe-hashes|\\\\*|data:|blob:)', header)"

condition: and

- type: dsl

name: unsafe-default-src

dsl:

- "contains(to_lower(header), 'content-security-policy:')"

- "regex('(?i)default-src[^;]*(unsafe-inline|unsafe-eval|unsafe-hashes|\\\\*|data:|blob:)', header)"

condition: and

extractors:

- type: regex

part: header

name: csp-header

group: 1

regex:

- "(?i)content-security-policy:\\s*([^\\r\\n]+)"

digest: 4b0a00483046022100dfaf6d69d97fd92defa1f4f6afb2961507c2d9377e5f84dbde6a6ef34b348f8802210081f1f8a44e6b6b5e12c7b13fd5a3e613a51ffce8876b4aa10b423ee88b690456:922c64590222798bb761d5b6d8e72950

```