Skip to content

Restrict the table browser to the databases and tables the explorer lists - #232

Open
Skyfay wants to merge 1 commit into
devfrom
Skyfay/table-browser-allowlist
Open

Skyfay wants to merge 1 commit into
devfrom
Skyfay/table-browser-allowlist

Conversation

@Skyfay

@Skyfay Skyfay commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Problem

The table browser took the database and table name straight from the request and read them with the login of the source. Someone with only sources:read could ask for a system database like mysql.global_priv (password hashes of the database accounts). On PostgreSQL a bare table name also resolved to pg_catalog first, so pg_authid could be read.

Fix

A read is now only allowed for what the explorer itself lists. The service checks the database against the adapter's database list and the table against its table list before any row is read. PostgreSQL looks up the schema of the table outside the system schemas and always names it in the query, so a bare name never reaches pg_catalog.

Changes

  • database-read-service.ts: listTables and readTableData refuse a database the connection does not list, and readTableData also refuses a table the listing does not have (a ValidationError).
  • postgres/browser.ts: new schema lookup that skips pg_catalog, information_schema, pg_toast and every pg_ schema. The count, data and column queries use the schema-qualified table, and the column query filters by schema.
  • A table with no match outside the system schemas is refused before the count or the rows run.
  • Unit tests for the service (system database, unlisted table, case-sensitive names, form configs) and for the PostgreSQL browser (pg_authid is never read as a bare name, schema lookup query).
  • Changelog fragment under Security, linked to GHSA-jqm8-vf23-56m9.

Testing

Unit tests were added and updated in tests/unit/services/database-read-service.test.ts and tests/unit/adapters/database/postgres-browser.test.ts. I have no evidence of a test run in this diff, so the result is TODO.

The table browser took the database and table of a request as they came and read them with the login of the source, so sources:read reached system schemas the listing hides, like mysql.global_priv. A read and a table listing now check both names against getDatabases and getTables first, and PostgreSQL names a table by its schema, so a bare name never resolves to pg_catalog.

This branch was successfully deployed

1 active deployment
e2e — e7086b39 Deployed Nov 28, 2026 by Skyfay via Approve #172
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