1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Commit Graph

17 Commits

Author SHA1 Message Date
Vladislav Vaintroub
85534724fa MDEV-41691 PROXY protocol v1 header parser is too lenient
Follow the specification: the line is at most 107 bytes including CRLF,
ends with CRLF (not a bare LF), and fields are separated by exactly one
space, with nothing trailing (except after UNKNOWN). Ports are decimal
numbers up to 65535, without signs or leading zeroes. Also reject NUL
bytes and unknown address families (these were accepted before).

test_proxy_header_limits() now checks that malformed headers are
rejected, and also avoid DNS name resolution.

Assisted-by: Claude:claude-sonnet-5-5
2026-10-23 12:43:19 +02:00
Vladislav Vaintroub
9660806dc9 MDEV-41508 Off-by-One Uninitialized Stack Read in Proxy Protocol V2 Port Parsing
parse_v2_header() required only 25 (TCPv4) / 49 (TCPv6) bytes, but then
reads the source port at hdr[25] / hdr[49]. A truncated header could make
it read uninitialized stack.

Require the whole address block: 28 bytes for TCPv4 and 52 for TCPv6.

Also, the declared header length was trusted without checking how many
bytes vio_read() returned. Reject short reads. The spec requires the
sender to send the header at once, and allows the receiver to drop the
connection on a partial header, so a single vio_read() is enough.

The v1 parser had the same problem on EOF: vio_read() returning 0 was
taken for a byte read, so the uninitialized buffer was parsed. Require
exactly one byte.

Extend test_proxy_header_tcp with a header cut short before the port,
and add test_proxy_header_short for a header shorter than it declares.

Light refactoring, to avoid repetition: added connect_tcp() and
init_v2_header(), which are now shared by several proxy header tests.

Assisted-by: Claude:claude-sonnet-5-5
2026-10-19 20:44:49 +02:00
Vladislav Vaintroub
ed38ffc01b MDEV-40967 PROXY protocol host check sent in clear text mid-SSL handshake
Defer the host-privileged/host-blocked check for a PROXY-header-derived
address until after the client's SSL handshake completes, instead of
sending it immediately in clear text.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 14:25:20 +02:00
Oleksandr Byelkin
0d59c434fa Merge branch '10.6' into 10.11 2026-06-21 15:32:20 +02:00
Sergei Golubchik
52bbe5b6e7 MDEV-39658 ASAN crash on invalid proxy_protocol_networks value
max_subnet estimate was off by one.

* only allow address with a known family
  (trips an assert in addr_matches_subnet())
* adjust max_subnet estimate accordinly
2026-05-20 22:49:20 +02:00
Sergei Golubchik
05663d1910 MDEV-39576 PROXY v2 protocol uninitialized memory reads 2026-05-20 22:49:20 +02:00
Sergei Golubchik
31319c7bc6 proxy protocol v2: fix a harmless typo
according to the rfc, the length is 2 bytes,
but the max length is 226 and there's a validity
check for length <= 240.
2026-05-20 22:49:20 +02:00
Sergei Golubchik
c5409caab0 MDEV-39564 One-byte OOB write in PROXY protocol v1 header parser 2026-05-20 22:49:20 +02:00
Vladislav Vaintroub
88a9b14f9f MDEV-39466 fix off-by-one stack buffer overflow in PROXY v1 header parsing
Make sure null terminator byte that is added at the end of header
is within boundaries of 'hdr' array.

This patch is based on https://github.com/MariaDB/server/pull/4881
by Uwez Khan
2026-04-28 21:10:46 +02:00
Sergei Golubchik
7c58e97bf6 perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
Vladislav Vaintroub
584ffa02f1 MDEV-19669 - fix matching CIDR address for proxy protocol.
Prior to this fix, when matching addresses using mask,
extra bits could be used for  comparison, e.g to
match with "a.b.c.d/24" , 27 bits were compared rather than 24.

The patch fixes the calculation.
2019-11-27 20:50:06 +01:00
Vladislav Vaintroub
131ed6c273 MDEV-15743 Avoid a PFS warning by shortening key name for proxy protocol rwlock 2018-04-02 22:49:32 +02:00
Vladislav Vaintroub
96ecf3ff23 MDEV-15501 : Make proxy_protocol_networks variable read-write. 2018-03-23 20:23:12 +00:00
Vladislav Vaintroub
6c279ad6a7 MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from 'size_t' to 'type', possible loss of data)
Handle string length as size_t, consistently (almost always:))
Change function prototypes to accept size_t, where in the past
ulong or uint were used. change local/member variables to size_t
when appropriate.

This fix excludes rocksdb, spider,spider, sphinx and connect for now.
2018-02-06 12:55:58 +00:00
Monty
a7e352b54d Changed database, tablename and alias to be LEX_CSTRING
This was done in, among other things:
- thd->db and thd->db_length
- TABLE_LIST tablename, db, alias and schema_name
- Audit plugin database name
- lex->db
- All db and table names in Alter_table_ctx
- st_select_lex db

Other things:
- Changed a lot of functions to take const LEX_CSTRING* as argument
  for db, table_name and alias. See init_one_table() as an example.
- Changed some function arguments from LEX_CSTRING to const LEX_CSTRING
- Changed some lists from LEX_STRING to LEX_CSTRING
- threads_mysql.result changed because process list_db wasn't always
  correctly updated
- New append_identifier() function that takes LEX_CSTRING* as arguments
- Added new element tmp_buff to Alter_table_ctx to separate temp name
  handling from temporary space
- Ensure we store the length after my_casedn_str() of table/db names
- Removed not used version of rename_table_in_stat_tables()
- Changed Natural_join_column::table_name and db_name() to never return
  NULL (used for print)
- thd->get_db() now returns db as a printable string (thd->db.str or "")
2018-01-30 21:33:55 +02:00
Vladislav Vaintroub
aaddac5cd7 fix compile errors 2017-08-23 08:27:46 +00:00
Vladislav Vaintroub
58cd69fc80 MDEV-11159 Server proxy protocol support
accept proxy protocol header from client connections.
The new server variable 'proxy_protocol_networks' contains list
of networks from which proxy header is accepted.
2017-08-22 21:08:38 +02:00