Bug 864612 - (CVE-2012-4505) CVE-2012-4505 libproxy: PAC handling insufficient content length check leading to buffer overflow
CVE-2012-4505 libproxy: PAC handling insufficient content length check leadin...
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20121012,repor...
: Security
Depends On: 872636 872637 874492
Blocks: 864423
  Show dependency treegraph
 
Reported: 2012-10-09 14:21 EDT by Tomas Hoger
Modified: 2015-11-24 10:20 EST (History)
5 users (show)

See Also:
Fixed In Version: libproxy 0.4
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-15 02:52:44 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
libproxy 0.3 patch (1.09 KB, patch)
2012-10-12 03:59 EDT, Tomas Hoger
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Debian BTS 690376 None None None 2012-10-14 12:36:27 EDT

  None (edit)
Description Tomas Hoger 2012-10-09 14:21:42 EDT
An insufficient input validation flaw, leading to a heap-based buffer overflow was found in libproxy 0.3.x in the px_pac_reload() function.  libproxy allocates a memory to store downloaded proxy.pac proxy auto-configuration file content using the Content-Length size from the remote server's HTTP response header.  Allocation size is content length + 1.  A malicious host hosting proxy.pac, or a man in the middle attacker, could use this flaw to make libproxy allocate insufficient amount of memory and subsequently overflow a heap-based buffer.

http://code.google.com/p/libproxy/source/browse/tags/libproxy-0.3.1/src/lib/pac.c#165

165      self->cache = px_malloc0(content_length+1);
166      for (int recvd=0 ; recvd != content_length ; )
167              recvd += recv(sock, self->cache + recvd, content_length - recvd, 0);

This issue was confirmed with libproxy 0.3.x.  Earlier 0.2.x versions seems to be affected too.  It does not affect 0.4.x versions, where fixed size buffer is used.
Comment 1 Tomas Hoger 2012-10-09 14:24:55 EDT
(In reply to comment #0)
> It does not affect 0.4.x versions, where fixed size buffer is used.

0.4.x versions were affected by a different overflow in the PAC loading code, see bug 864417.  This problem was discovered while investigating the 0.4.x issue.
Comment 3 Tomas Hoger 2012-10-09 14:51:32 EDT
Acknowledgment:

This issue was discovered by the Red Hat Security Response Team.
Comment 5 Tomas Hoger 2012-10-12 03:59:23 EDT
Created attachment 625842 [details]
libproxy 0.3 patch

Proposed patch for libproxy 0.3.x.  It introduces the same PAC_MAX_SIZE as used in 0.4 (102400) and uses it as the maximum acceptable proxy.pac file size, avoiding integer wraparound on +1.  It also adds recv return value checks.
Comment 6 Tomas Hoger 2012-10-12 04:07:32 EDT
Semi-public now via upstream announcement of the 0.4.9 version, which fixes similar CVE-2012-4504 which affected 0.4.x versions:

https://groups.google.com/forum/?fromgroups=#!topic/libproxy/VxZ8No7mT0E

Making bug public.
Comment 16 errata-xmlrpc 2012-11-14 15:31:59 EST
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2012:1461 https://rhn.redhat.com/errata/RHSA-2012-1461.html

Note You need to log in before you can comment on or make changes to this bug.