Details
Description
When reading result-set or prepare metadata, the driver allocates a ColumnDecoder array sized to the column count announced by the server (a length-encoded integer, up to Integer.MAX_VALUE). A malicious man-in-the-middle proxy can announce an enormous column count to force a huge allocation and exhaust client memory (OOM), before any actual column packets are read.
Add a new connection option maxAllowedColumns (default 65535) that rejects the command with an SQLException when the announced column count exceeds the limit, before allocating. 65535 matches the wire-format cap already imposed on prepare-statement column/param counts.
MariadDB/MySQL tables columns limit is 4k (1017 for InnoDB), so 64K limit is ok.
thanks fg0x0 for report