Skip to content

security(sqlsafety): deny side-effecting functions in read-only vxd db sql (P0-05)#116

Merged
tzone85 merged 1 commit into
mainfrom
fix/p0-05-sql-function-denylist
Jul 16, 2026
Merged

security(sqlsafety): deny side-effecting functions in read-only vxd db sql (P0-05)#116
tzone85 merged 1 commit into
mainfrom
fix/p0-05-sql-function-denylist

Conversation

@tzone85

@tzone85 tzone85 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • READ ONLY transactions do not block pg_terminate_backend, lo_import, pg_read_file and friends — on a shared devdb host any local user could kill or snoop another user's session through vxd db sql without --write.
  • New sqlsafety.ContainsDeniedFunction call-shape matcher (whole identifier + open paren) over the comment/string-stripped query; built-in denylist of 8 catalog functions plus operator extras via new devdb.function_denylist_extra config knob.
  • ValidateSQL(query, writeFlag, extraDeny) rejects hits in read-only mode; --write (explicit opt-in) skips the denylist. ValidateSQLForReadOnly delegates unchanged.

Tests

  • TestSQLSafety_FunctionDenylist — 15 denied cases (case-insensitivity, whitespace, schema-qualified, comment-ambush reassembly) + 5 non-matching (near-miss identifiers, quoted/comment mentions).
  • TestSQLSafety_DenylistExtraConfig — operator extras denied, blank entries ignored.

Closes WEAKNESSES.md P0-05.

🤖 Generated with Claude Code

…b sql

READ ONLY transactions do not block pg_terminate_backend, lo_import,
pg_read_file and friends — on a shared devdb host any local user could
kill or snoop another user's session through vxd db sql without --write.

- sqlsafety.ContainsDeniedFunction: call-shape matcher (whole identifier
  + open paren) over the comment/string-stripped query; built-in denylist
  of 8 catalog functions plus operator extras.
- ValidateSQL(query, writeFlag, extraDeny) — read-only mode rejects any
  hit; --write (explicit opt-in) skips the denylist. Old
  ValidateSQLForReadOnly delegates unchanged.
- New devdb.function_denylist_extra config knob, wired into vxd db sql.
- Tests: TestSQLSafety_FunctionDenylist (15 denied incl. case/whitespace/
  schema-qualified/comment-ambush + 5 non-matching), _DenylistExtraConfig.
- Docs: CLAUDE.md CLI row + devdb block, README devdb section.

Closes WEAKNESSES.md P0-05.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tzone85
tzone85 merged commit 3dd5ca5 into main Jul 16, 2026
5 checks passed
@tzone85
tzone85 deleted the fix/p0-05-sql-function-denylist branch July 16, 2026 02:14
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.

2 participants