What it is: Use of Non-Canonical URL Paths for Authorization Decisions (CWE-647) is a vulnerability where web applications rely on canonical URLs to enforce access controls, allowing attackers to bypass these controls using non-canonical paths.
Why it matters: This weakness can lead to unauthorized access and compromise of sensitive data in web applications. Attackers exploit this by using alternate URL representations that still point to the same resource but are not recognized as canonical.
How to fix it: Canonicalize URLs before making authorization decisions, ensuring only expected path formats can be accessed.
TL;DR: Use of Non-Canonical URL Paths for Authorization Decisions (CWE-647) is a vulnerability where web applications rely on canonical URLs to enforce access controls, allowing attackers to bypass these controls using non-canonical paths. Ensure only expected path formats can be accessed by canonicalizing URLs before making authorization decisions.
| Field | Value |
|---|---|
| CWE ID | CWE-647 |
| OWASP Category | Not directly mapped |
| CAPEC | None known |
| Typical Severity | High |
| Affected Technologies | web applications, URL routing |
| Detection Difficulty | Moderate |
| Last Updated | 2026-07-29 |
What is Use of Non-Canonical URL Paths for Authorization Decisions?
Use of Non-Canonical URL Paths for Authorization Decisions (CWE-647) is a type of access control vulnerability that occurs when web applications rely on the canonical form of URLs to enforce authorization policies. As defined by the MITRE Corporation under CWE-647, and classified by the OWASP Foundation under [mapping], this weakness allows attackers to bypass these controls using non-canonical URL representations.
Quick Summary
Use of Non-Canonical URL Paths for Authorization Decisions is a serious security flaw that enables unauthorized access to protected resources through alternate but equivalent URLs. This vulnerability undermines the integrity of web application authorization mechanisms and poses significant risks to data confidentiality. Jump to: Overview · How It Works · Business Impact · Attack Scenario · Detection · Remediation
Jump to: Quick Summary · Use of Non-Canonical URL Paths for Authorization Decisions Overview · How Use of Non-Canonical URL Paths for Authorization Decisions Works · Business Impact of Use of Non-Canonical URL Paths for Authorization Decisions · Use of Non-Canonical URL Paths for Authorization Decisions Attack Scenario · How to Detect Use of Non-Canonical URL Paths for Authorization Decisions · How to Fix Use of Non-Canonical URL Paths for Authorization Decisions · Framework-Specific Fixes for Use of Non-Canonical URL Paths for Authorization Decisions · How to Ask AI to Check Your Code for Use of Non-Canonical URL Paths for Authorization Decisions · Use of Non-Canonical URL Paths for Authorization Decisions Best Practices Checklist · Use of Non-Canonical URL Paths for Authorization Decisions FAQ · Vulnerabilities Related to Use of Non-Canonical URL Paths for Authorization Decisions · References · Scan Your Own Site
Use of Non-Canonical URL Paths for Authorization Decisions Overview
What
Use of Non-Canonical URL Paths for Authorization Decisions is a vulnerability where web applications rely on canonical URLs to enforce access controls, allowing attackers to bypass these controls using non-canonical paths.
Why it matters
This weakness can lead to unauthorized access and compromise of sensitive data in web applications. Attackers exploit this by using alternate URL representations that still point to the same resource but are not recognized as canonical.
Where it occurs
This vulnerability typically affects web applications that define policy namespaces based on URL paths without proper validation or normalization.
Who is affected
Web application developers, administrators, and users who rely on access control mechanisms for securing sensitive resources are at risk if non-canonical URLs can bypass these controls.
Who is NOT affected
Applications that validate and normalize all input URLs before making authorization decisions are not vulnerable to this weakness.
How Use of Non-Canonical URL Paths for Authorization Decisions Works
Root Cause
The root cause lies in the assumption that a URL’s canonical form will always be used when enforcing access control policies. When non-canonical forms are accepted, attackers can bypass these controls.
Attack Flow
- An attacker identifies an application endpoint with weak authorization checks based on URLs.
- The attacker crafts a non-canonical URL path to access protected resources without proper authorization.
- If the server accepts this non-canonical form, it grants unauthorized access to sensitive data or functionality.
- The attacker exploits the vulnerability to gain illicit access and perform actions that should be restricted by policy.
Prerequisites to Exploit
- The application must accept non-canonical URL paths as valid input.
- Access control policies must rely on canonical forms of URLs for enforcement.
Vulnerable Code
def get_resource(request): path = request.path_info resource = open(path, 'r')This code is vulnerable because it directly uses the unnormalized
request.path_infoto access resources without validating or normalizing the URL path.
Secure Code
import re
def get_resource(request):
canonical_path = normalize_url_path(request.path_info)
if not validate_canonical_path(canonical_path):
raise ValueError('Invalid path')
resource = open(canonical_path, 'r')
def normalize_url_path(path):
# Normalize the URL path to its canonical form
return os.path.normpath(path)
def validate_canonical_path(path):
# Validate that the normalized path matches expected patterns
pattern = re.compile(r'^/path/to/resource(/|$)')
return bool(pattern.match(path))
The secure code ensures that the URL path is first normalized to its canonical form and then validated against restrictive regular expressions before accessing resources.
Business Impact of Use of Non-Canonical URL Paths for Authorization Decisions
Confidentiality
- Unauthorized access to sensitive data through non-canonical URLs.
- Exposure of private information due to bypassed authorization checks.
Integrity
- Modification or tampering with protected resources via crafted paths.
Availability
- Potential disruption of service if critical endpoints are exploited.
Use of Non-Canonical URL Paths for Authorization Decisions Attack Scenario
- The attacker identifies a web application endpoint that uses non-canonical URLs to enforce access controls.
- They craft a non-canonical path like
../file.txtinstead of/path/to/file.txt. - If the server accepts this form, it grants unauthorized read/write access to protected resources.
- The attacker exploits the vulnerability by accessing sensitive data or performing actions that should be restricted.
How to Detect Use of Non-Canonical URL Paths for Authorization Decisions
Manual Testing
- Verify that all URLs are canonicalized before making authorization decisions.
- Test endpoints with non-canonical paths to ensure they enforce proper access controls.
- Check if the application normalizes and validates URL paths correctly.
Automated Scanners (SAST / DAST)
Static analysis can detect code patterns where URLs are used directly without normalization or validation. Dynamic testing is necessary to confirm that non-canonical forms are rejected at runtime.
PenScan Detection
PenScan’s ZAP, Nuclei, Wapiti, and Nikto scanners actively test for this vulnerability by sending non-canonical URL paths and evaluating the server’s response.
False Positive Guidance
A true positive will show an endpoint accepting a non-canonical path that bypasses authorization checks. A false positive may occur if canonicalization is already enforced or if patterns are flagged without actual exploitation.
How to Fix Use of Non-Canonical URL Paths for Authorization Decisions
- Canonicalize URLs before making any access control decisions.
- Validate paths against restrictive regular expressions to ensure they match expected forms.
- Reject all alternate path encodings that do not conform to the canonical form.
- Implement strict validation mechanisms to prevent non-canonical URLs from being processed.
Framework-Specific Fixes for Use of Non-Canonical URL Paths for Authorization Decisions
Python/Django
from django.http import HttpResponse
def get_resource(request):
path = normalize_url_path(request.path_info)
if not validate_canonical_path(path):
return HttpResponse("Invalid path", status=403)
resource = open(path, 'r')
How to Ask AI to Check Your Code for Use of Non-Canonical URL Paths for Authorization Decisions
Review the following Python code block for potential CWE-647 Use of Non-Canonical URL Paths for Authorization Decisions vulnerabilities and rewrite it using canonicalization techniques: [paste code here]
Use of Non-Canonical URL Paths for Authorization Decisions Best Practices Checklist
✅ Canonicalize URLs before making authorization decisions. ✅ Validate paths against restrictive regular expressions to ensure they match expected forms. ✅ Reject all alternate path encodings that do not conform to the canonical form. ✅ Implement strict validation mechanisms to prevent non-canonical URLs from being processed. ✅ Test endpoints with non-canonical paths to confirm proper access control enforcement.
Use of Non-Canonical URL Paths for Authorization Decisions FAQ
How does the use of non-canonical URLs affect authorization mechanisms?
The vulnerability arises when an application relies on a canonical form of a URL to enforce access controls, allowing attackers to bypass these controls by using alternative but equivalent paths.
Can you provide an example of how this weakness can be exploited in real-world applications?
An attacker could use non-canonical URLs like ‘../file.txt’ instead of ‘/path/to/file.txt’, potentially accessing protected resources without proper authorization checks.
What steps should developers take to prevent this vulnerability?
Developers should ensure that URL paths are canonicalized before performing any access control decisions, and validate them against restrictive regular expressions to confirm they match expected forms.
How does Use of Non-Canonical URL Paths for Authorization Decisions relate to the CIA triad?
This weakness primarily impacts confidentiality by allowing unauthorized access to sensitive data through non-canonical paths.
What are some common false positives when detecting this vulnerability?
False positives may occur if a scanner flags canonicalization checks that are already in place or if it detects patterns that do not actually bypass authorization mechanisms.
How can I check my code for Use of Non-Canonical URL Paths for Authorization Decisions using an AI assistant?
Review the following Python code block for potential CWE-647 vulnerabilities and rewrite it to ensure paths are canonicalized before making access control decisions: [paste code here]
What is the recommended approach to mitigate this vulnerability in web applications?
Implement strict path validation using regular expressions that enforce a specific canonical form, rejecting any non-canonical variants.
Vulnerabilities Related to Use of Non-Canonical URL Paths for Authorization Decisions
| CWE | Name | Relationship | |—|—|—| | 863 | Incorrect Authorization (ChildOf) |
References
Scan Your Own Site
Manual code review catches what you know to look for. An automated scan catches what you didn’t. Scan your own website using PenScan to find Use of Non-Canonical URL Paths for Authorization Decisions and other risks before an attacker does.