Skip to content

Don't make the rows the database gives taint sources - #168

Merged
danog merged 1 commit into
psalm:2.xfrom
danog:strict-database-rows
Nov 18, 2026
Merged

danog merged 1 commit into
psalm:2.xfrom
danog:strict-database-rows

Conversation

@danog

@danog danog commented Nov 18, 2026

Copy link
Copy Markdown
Member

Every row DBAL or an ORM query gives is reported as tainted, even when no query stored user input in it.

Before

<?php
echo (string) connection()->fetchOne('SELECT name FROM users'); // TaintedHtml
echo (string) query()->getSingleScalarResult();                 // TaintedHtml

After

echo (string) connection()->fetchOne('SELECT name FROM users'); // no issue
echo (string) query()->getSingleScalarResult();                 // no issue

The queries stay SQL sinks. What a query stores flowing to the queries reading it will come from vimeo/psalm#14159's @psalm-database-* annotations, once a Psalm release has them.

A row holds user input only if a query stored it there, which Psalm follows
from the queries storing values to those reading them (vimeo/psalm#14159), not
by default. The queries stay SQL sinks.
@danog
danog merged commit b6491aa into psalm:2.x Nov 18, 2026
12 checks passed
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