Skip to content

Company Size Filter SQL prüfen#77

Closed
flolanger wants to merge 1 commit into
developfrom
bugfix/sql-injection-filter-size-revenue-class
Closed

Company Size Filter SQL prüfen#77
flolanger wants to merge 1 commit into
developfrom
bugfix/sql-injection-filter-size-revenue-class

Conversation

@flolanger

@flolanger flolanger commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

[Claude Code]

Problem

FilterDto::getSizeClass() und getRevenueClass() werden in AbstractRepository unquotiert in rohes SQL eingefügt (Company-/Pagevisit-Filter). Die Werte durchlaufen nur die Denylist StringUtility::sanitizeString(), die Leerzeichen, Kommas, Ziffern und SQL-Schlüsselwörter durchlässt.

Fix

Beide Werte an der Konkatenationsstelle nach int casten – analog zum bestehenden branch_code. Der Filter enthält ausschließlich numerische Klassen-Codes, das Verhalten für legitime Eingaben bleibt unverändert.

Tests

Neuer AbstractRepositoryTest belegt, dass die Fragmente nicht mehr injizierbar sind. Unit-Suite grün (203 Tests), php-cs-fixer sauber.

CompanyRepository::findByFilter()/findAmountByFilter() (and
PagevisitRepository::findLatestPagevisitsWithCompanies()) build raw SQL
by concatenating FilterDto::getSizeClass() and getRevenueClass()
unquoted into the WHERE clause. Those getters only apply the
StringUtility::sanitizeString() denylist, which leaves spaces, commas,
digits and SQL keywords intact. A backend user with access to the Lead
module could therefore inject SQL through the company size/revenue
class filter (e.g. UNION-based reads of other tables and bypass of the
per-site scoping enforced via getSitesForFilter()).

Cast both values to int at the point of concatenation, mirroring the
existing branch_code handling in the same class. The filter only ever
carries numeric class codes and the previous unquoted comparison was
already interpreted numerically by the database, so behaviour is
unchanged for legitimate input.

Adds a unit test that proves the size_class/revenue_class fragments are
no longer injectable.
@flolanger flolanger changed the title [SECURITY] SQL-Injection über Größen-/Umsatzklassen-Filter beheben Company Size Filter SQL prüfen Jul 22, 2026
@flolanger

Copy link
Copy Markdown
Contributor Author

After Review: AI Changes are not quite the solution, we need to look into this further first.

@flolanger flolanger closed this Jul 23, 2026
@einpraegsam
einpraegsam deleted the bugfix/sql-injection-filter-size-revenue-class branch July 23, 2026 10:59
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