Path Traversal Protection
Protection Module: PathTraversal
Prevents path traversal attacks that attempt to access files outside the intended directory.
Available for:
- ASP.NET Core
- ASP.NET Framework
- Azure Functions
How It Works
Path Traversal Protection validates file paths to prevent unauthorized directory access.
Detection Methods:
- Directory Traversal Patterns - Identifies
../,..\, and encoded variants - Absolute Path Detection - Detects attempts to use absolute paths
- UNC Path Detection - Identifies network path access attempts
- Null Byte Injection - Detects null byte truncation attacks
- URL Encoding Bypass - Identifies encoded traversal attempts
- Unicode Normalization - Detects unicode-based bypasses
Attack Types Detected:
- Classic directory traversal (
../../../etc/passwd) - Windows path traversal (
..\..\..\windows\system32) - Double encoding (
%252e%252e%252f) - URL encoding (
..%2F..%2F) - Unicode variants (
%c0%ae%c0%ae/)
Configuration
JSON
{
"protections": {
"PathTraversal": {
"enabled": true,
"action": "block"
}
}
}{
"protections": {
"PathTraversal": {
"enabled": true,
"action": "block"
}
}
}ASP.NET Core
C#
builder.Services.AddBytehideMonitor(monitor => monitor
.WithProtection(ProtectionModuleType.PathTraversal, ActionType.Block)
);builder.Services.AddBytehideMonitor(monitor => monitor
.WithProtection(ProtectionModuleType.PathTraversal, ActionType.Block)
);Attack Examples
Classic Traversal
HTTP
GET /files?path=../../../etc/passwd
Status: BLOCKEDGET /files?path=../../../etc/passwd
Status: BLOCKEDWindows Traversal
HTTP
GET /download?file=..\..\..\windows\system32\config\sam
Status: BLOCKEDGET /download?file=..\..\..\windows\system32\config\sam
Status: BLOCKEDURL Encoded
HTTP
GET /files?path=..%2f..%2f..%2fetc%2fpasswd
Status: BLOCKEDGET /files?path=..%2f..%2f..%2fetc%2fpasswd
Status: BLOCKEDNull Byte Injection
HTTP
GET /files?path=../../../etc/passwd%00.jpg
Status: BLOCKEDGET /files?path=../../../etc/passwd%00.jpg
Status: BLOCKEDPlatform Compatibility
| Platform | Support |
|---|---|
| ASP.NET Core | ✔ |
| ASP.NET Framework | ✔ |
| Azure Functions | ✔ |
Related Protections
Actions
Configure responses