Skip to content

fix(security): findings of the review of the guard, the detector and the zip extractor - #1797

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
fix/review-security
Oct 25, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
fix/review-security

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

From two independent read-only reviews of what was merged in the last session (#1765, #1769, #1770).

Update zip (#1765). Entries were checked by name only. An archive with a -> ., a/b -> .. and a file b/evil wrote outside the extraction root. Now any entry whose parent directory chain contains a symlink already on disk is refused.

MCP SQL guard (#1769).

  • Refused as ambiguous_syntax: a quoted identifier holding --, ', # or /* (read left to right, so ordinary quoting is not affected), a PostgreSQL U&"..." identifier, MySQL # comments and MySQL -- without a following space. The comment/string stripper and the server read these differently, which let SELECT 1 AS "--", pg_sleep(100) and SELECT 1--1, SLEEP(30) through.
  • Denylist: pg_notify, pg_ls_*, pg_stat_*reset*, pg_logical_* (slot get/peek changes), pg_replication_*, pg_create_*_slot, pg_copy_*_slot, pg_backup_*.

Destructive detector (#1770).

  • A data-modifying CTE (WITH d AS (DELETE FROM t RETURNING *) SELECT ...) is inspected.
  • After WITH the scan stops at the main statement keyword, so an upsert's ON CONFLICT DO UPDATE and a column called delete are no longer flagged.
  • DELETE FROM orders o USING (SELECT 1 FROM t ...) names orders, not t (the optional group is lazy now); the modifier group that backtracked quadratically is gone.
  • ALTER TABLE t DROP col (COLUMN is optional), DROP FOREIGN/TEMPORARY TABLE, DROP EVENT TRIGGER, DROP SERVER, DROP OWNED BY.

Tests for each. Not run locally, CI will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant