Repository navigation
feat: make the raw SQL slots impossible to whitelist - #475
Merged
Merged
Conversation
A pinned [data.connect] only chooses the database a connection opens. Raw SQL text reaches every other database the login can - ATTACH in SQLite, cross-database names in MySQL and SQL Server, server functions in PostgreSQL - so a sandbox granted [data.select] next to a pinned connection could read and write Magic's own database and create a root user. That cannot be confined from the application side. [select], [scalar] and [execute] for [data] and all four dialects now declare Whitelistable = false, so a [whitelist] naming any of them is refused when it is declared. Sandboxes use [data.read], [data.create], [data.update] and [data.delete], which build their own SQL. Bumps the version to v24.5.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
polterguy
added a commit
to polterguy/hyperlambda-generator-eval
that referenced
this pull request
Dec 5, 2026
Magic no longer lets a [whitelist] grant the raw SQL slots, since a pinned connection does not confine SQL text (polterguy/magic#475). Both reference solutions granted them, so they now grant the read slot instead, and their cases use a read in place of SQL text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes the second case in the appendix of the external security review of 1 December.
The problem
Pinning
data.connect:chinookin a[whitelist]only chooses which database the connection opens. Raw SQL text reaches any other database the login can:ATTACH 'files/data/magic.db', which the researcher used to read the users table, insert a root user and log in as rootmagic.users,magic.dbo.users)pg_read_file,COPY ... FROM PROGRAM,dblinkPolicing arbitrary SQL across four dialects from the application side is a blacklist that can't be won. The only real boundary for raw SQL is database-level permissions, which a pin doesn't provide.
The change
select,scalarandexecutefordata.*,sqlite.*,mysql.*,pgsql.*andmssql.*(15 slots) now declareWhitelistable = false. A[whitelist]naming any of them is refused when it's declared, the same as thetasks.*,io.file.saveandgit.*slots.data.*is included as well as the dialect slots, so neither layer is left open.data.read,data.create,data.updateanddata.delete, which build their own SQL.WhitelistableTests.NeverWhitelistablelists the 15 names, and its comment explains why.Breaking for sandboxes that grant raw SQL
A
[whitelist]that lists any of these slots now throws[data.select] can never be used inside a [whitelist]. Known places:282-sandbox-allow-one-database.hland292-sandbox-pinned-database.hlgrantdata.select/sqlite.scalar, so both will now fail. They're left unchanged here, for the eval owner to decide.Not built or tested locally; CI runs the analyzer build and the tests.
Bumps the version to v24.5.4.
🤖 Generated with Claude Code