TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python urllib CRLF injection vulnerability

94 pointsby robin0about 6 years ago

9 comments

kccqzyabout 6 years ago
This is far from uncommon. Back in DEFCON 2017 Orange Tsai gave a talk about inconsistencies in different URL parsing libraries in different languages. The opening example was a single URL that had a different hostname when parsed by urllib, urllib2, and requests. He also demoed examples of using unusual characters like spaces and newlines to talk to Redis or SMTP while pretending to be HTTP.<p>Slides: <a href="https:&#x2F;&#x2F;media.defcon.org&#x2F;DEF%20CON%2025&#x2F;DEF%20CON%2025%20presentations&#x2F;DEFCON-25-Orange-Tsai-A-New-Era-of-SSRF-Exploiting-URL-Parser%20in-Trending-Programming-Languages-UPDATED.pdf" rel="nofollow">https:&#x2F;&#x2F;media.defcon.org&#x2F;DEF%20CON%2025&#x2F;DEF%20CON%2025%20pre...</a>
评论 #19424148 未加载
评论 #19423903 未加载
haikugingerabout 6 years ago
Python urllib3 maintainer here. urllib3 made a change to be more RFC-compliant in December, and which fixed this issue, but that change has not been released yet. We are in the process of looking into that.<p>I have verified that Requests, which uses us, appears to have its own handling, back at least to requests 2.0 (released in 2013) that prevents this when used directly as an abstraction layer on top of urllib3.
评论 #19424003 未加载
cbsksabout 6 years ago
The link should probably be changed to the actual bug: <a href="https:&#x2F;&#x2F;bugs.python.org&#x2F;issue36276" rel="nofollow">https:&#x2F;&#x2F;bugs.python.org&#x2F;issue36276</a>
评论 #19422966 未加载
jaybosamiyaabout 6 years ago
Relevant (and super cool) previous work, done by Orange Tsai: <a href="https:&#x2F;&#x2F;www.blackhat.com&#x2F;docs&#x2F;us-17&#x2F;thursday&#x2F;us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-Languages.pdf" rel="nofollow">https:&#x2F;&#x2F;www.blackhat.com&#x2F;docs&#x2F;us-17&#x2F;thursday&#x2F;us-17-Tsai-A-Ne...</a>
1wdabout 6 years ago
Python 3 urllib and other stdlib protocol modules also use `splitlines` which splits on various unicode &quot;newlines&quot;. Could that also be exploitable somehow? <a href="https:&#x2F;&#x2F;discuss.python.org&#x2F;t&#x2F;changing-str-splitlines-to-match-file-readlines&#x2F;174" rel="nofollow">https:&#x2F;&#x2F;discuss.python.org&#x2F;t&#x2F;changing-str-splitlines-to-matc...</a>
peterwwillisabout 6 years ago
Key takeaway: don&#x27;t expect a library to do the safe thing; always sanitize all your input. (If your language supports taint mode, enabling it can prevent these bugs)
anaphorabout 6 years ago
Does anyone know if this also affects the Requests library? Does it use these under the hood, or is it all httplib? (I&#x27;m pretty sure that&#x27;s the case)
评论 #19423025 未加载
评论 #19423015 未加载
vldoabout 6 years ago
seems like an ad for coocoor<p>actual CVE entry: <a href="http:&#x2F;&#x2F;cve.mitre.org&#x2F;cgi-bin&#x2F;cvename.cgi?name=CVE-2019-9740" rel="nofollow">http:&#x2F;&#x2F;cve.mitre.org&#x2F;cgi-bin&#x2F;cvename.cgi?name=CVE-2019-9740</a>
hannobabout 6 years ago
Probably worth checking other implementations. The comments already mention that urllib3 is affected as well.
评论 #19423017 未加载
评论 #19423282 未加载