haproxy/src
Willy Tarreau 67dad2715b BUG/CRITICAL: fix a possible crash when using negative header occurrences
When a config makes use of hdr_ip(x-forwarded-for,-1) or any such thing
involving a negative occurrence count, the header is still parsed in the
order it appears, and an array of up to MAX_HDR_HISTORY entries is created.
When more entries are used, the entries simply wrap and continue this way.

A problem happens when the incoming header field count exactly divides
MAX_HDR_HISTORY, because the computation removes the number of requested
occurrences from the count, but does not care about the risk of wrapping
with a negative number. Thus we can dereference the array with a negative
number and randomly crash the process.

The bug is located in http_get_hdr() in haproxy 1.5, and get_ip_from_hdr2()
in haproxy 1.4. It affects configurations making use of one of the following
functions with a negative <value> occurence number :

   - hdr_ip(<name>, <value>)  (in 1.4)
   - hdr_*(<name>, <value>)   (in 1.5)

It also affects "source" statements involving "hdr_ip(<name>)" since that
statement implicitly uses -1 for <value> :

   - source 0.0.0.0 usesrc hdr_ip(<name>)

A workaround consists in rejecting dangerous requests early using
hdr_cnt(<name>), which is available both in 1.4 and 1.5 :

   block if { hdr_cnt(<name>) ge 10 }

This bug has been present since the introduction of the negative offset
count in 1.4.4 via commit bce70882. It has been reported by David Torgerson
who offered some debugging traces showing where the crash happened, thus
making it significantly easier to find the bug!

CVE-2013-2175 was assigned to this bug.

This fix must absolutely be backported to 1.4.
2013-06-17 12:00:22 +02:00
..
acl.c BUG/MINOR: acl: correctly consider boolean fetches when doing casts 2013-06-12 22:26:05 +02:00
appsession.c MEDIUM: make the trash be a chunk instead of a char * 2012-10-29 16:57:30 +01:00
arg.c MAJOR: sample: maintain a per-proxy list of the fetch args to resolve 2013-04-03 02:13:02 +02:00
auth.c
backend.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
base64.c
buffer.c CLEANUP: buffer: use buffer_empty() instead of buffer_len()==0 2012-12-17 01:14:49 +01:00
cfgparse.c MEDIUM: http: add a new "http-response" ruleset 2013-06-11 16:06:12 +02:00
channel.c OPTIM: channel: inline channel_forward's fast path 2012-10-26 01:08:01 +02:00
checks.c MEDIUM: protocol: implement a "drain" function in protocol layers 2013-06-10 20:33:23 +02:00
chunk.c MINOR: chunks: centralize the trash chunk allocation 2012-12-23 21:46:07 +01:00
compression.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
connection.c BUG/MEDIUM: connection: always update connection flags prior to computing polling 2012-12-17 01:14:25 +01:00
cttproxy.c CLEANUP: cttproxy: remove a warning on undeclared close() 2012-10-05 22:18:07 +02:00
dumpstats.c BUG/MEDIUM: stats: allocate the stats frontend also on "stats bind-process" 2013-04-20 09:48:50 +02:00
ev_epoll.c BUG/MINOR: epoll: use a fix maxevents argument in epoll_wait() 2013-01-18 15:31:03 +01:00
ev_kqueue.c BUG/MINOR: poll: the I/O handler was called twice for polled I/Os 2012-12-14 00:17:03 +01:00
ev_poll.c MEDIUM: poll: do not use FD_* macros anymore 2013-03-31 15:01:01 +02:00
ev_select.c BUG/MAJOR: ev_select: disable the select() poller if maxsock > FD_SETSIZE 2013-03-31 15:01:05 +02:00
fd.c BUG: polling: don't skip polled events in the spec list 2012-11-12 01:57:14 +01:00
freq_ctr.c BUG/MINOR: time: frequency counters are not totally accurate 2012-12-29 21:50:07 +01:00
frontend.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
haproxy-systemd-wrapper.c BUILD: stdbool is not portable (again) 2013-05-01 10:09:30 +02:00
haproxy.c CLEANUP: fix minor typo in error message. 2013-05-14 20:56:28 +02:00
hdr_idx.c
i386-linux-vsys.c MEDIUM: listener: add support for linux's accept4() syscall 2012-10-08 20:11:03 +02:00
lb_chash.c BUG/MAJOR: backend: consistent hash can loop forever in certain circumstances 2013-04-12 14:46:51 +02:00
lb_fas.c
lb_fwlc.c
lb_fwrr.c
lb_map.c
listener.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
log.c MEDIUM: log: add a log level override value in struct session 2013-06-11 17:50:26 +02:00
memory.c
payload.c MEDIUM: acl: remove 15 additional useless ACLs that are equivalent to their fetches 2013-06-12 22:23:40 +02:00
peers.c MEDIUM: log: add a log level override value in struct session 2013-06-11 17:50:26 +02:00
pipe.c
proto_http.c BUG/CRITICAL: fix a possible crash when using negative header occurrences 2013-06-17 12:00:22 +02:00
proto_tcp.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
proto_uxst.c MAJOR: listener: support inheriting a listening fd from the parent 2013-03-11 01:30:01 +01:00
protocol.c REORG: split "protocols" files into protocol and listener 2012-09-15 22:29:32 +02:00
proxy.c MEDIUM: http: add a new "http-response" ruleset 2013-06-11 16:06:12 +02:00
queue.c MAJOR: connection: replace struct target with a pointer to an enum 2012-11-12 00:42:33 +01:00
raw_sock.c BUG/MEDIUM: splicing is broken since 1.5-dev12 2013-04-06 11:46:27 +02:00
rbtree.c
regex.c
sample.c MAJOR: sample: maintain a per-proxy list of the fetch args to resolve 2013-04-03 02:13:02 +02:00
server.c MEDIUM: server: Tighten up parsing of weight string 2013-02-13 10:59:50 +01:00
session.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
sessionhash.c
shctx.c BUG/MEDIUM: shctx: makes the code independent on SSL runtime version. 2013-04-26 19:15:52 +02:00
signal.c BUG/MEDIUM: signal: signal handler does not properly check for signal bounds 2013-01-24 16:19:19 +01:00
ssl_sock.c MEDIUM: acl: remove a lot of useless ACLs that are equivalent to their fetches 2013-06-11 21:22:58 +02:00
standard.c MEDIUM: stats: add proxy name filtering on the statistic page 2013-04-15 22:50:33 +02:00
stick_table.c MEDIUM: counters: add a new "gpc0_rate" counter in stick-tables 2013-05-29 15:54:14 +02:00
stream_interface.c BUG/MEDIUM: stream_interface: don't close outgoing connections on shutw() 2012-12-30 01:39:37 +01:00
task.c
time.c BUG/MINOR: time: frequency counters are not totally accurate 2012-12-29 21:50:07 +01:00
trace.c MINOR: add a new function call tracer for debugging purposes 2012-05-26 00:12:37 +02:00
uri_auth.c BUG/MEDIUM: uri_auth: missing NULL check and memory leak on memory shortage 2013-01-24 16:19:19 +01:00