A heap-based buffer overflow vulnerability exists in PostgreSQL foreign data wrapper (FDW) batch inserts. This flaw allows a foreign server to execute arbitrary code by reporting that it inserted more rows than the server actually supplied. The issue arises when postgres_fdw encounters a rule on the remote table that expands an INSERT into additional rows. Versions prior to PostgreSQL 14.25, 15.20, 16.16, 17.12, and 18.7 are affected.