Skip to content

Host Header Injection

Description

Using untrusted Host header for generating dynamic URLs can result in web cache and or password reset poisoning.

Examples

Insecure Code

javascript
var url = 'https://' + req.host + '/path';

Secure Code

javascript
var url = 'https://' + sanitize(req.host) + '/path';

Remediation

Validate and sanitize the Host header before using it to generate dynamic URLs.

Rule Details

FieldValue
IDCODE-0401
CategoryInjection
SeverityMEDIUM
CWECWE-348
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
TagsHost Header Injection, Web Cache Poisoning, Password Reset Poisoning
OWASPA1:2017-Injection, A03:2021-Injection