URL length not validated; inputs >128 chars cause unhandled 500 error #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The
originalcolumn is defined aschar(128)in the database. The controller validates that the submitted value is a syntactically valid URL (via Symfony'sUrlconstraint) but does not enforce a length limit. A URL longer than 128 characters passes validation and is handed to Doctrine, which throws an uncaught exception when MySQL rejects the oversized value.Location
src/Entity/Links.php, line 17:#[ORM\Column(length: 128)]src/Controller/Shortener.php, lines 22–27 — validation checks only URL format, noLengthconstraintRisk
Submitting any valid URL exceeding 128 characters produces an unhandled 500 error instead of a user-friendly message. Many real-world URLs (e.g., URLs with query strings) routinely exceed 128 characters, making this a common reliability failure. Depending on Symfony's error display configuration, the stack trace could leak internal path or database information.
Suggested fix direction
Add a
Length(max: 2048)constraint alongside the existingUrlconstraint in the controller, and increase theoriginalcolumn size to match (e.g.,#[ORM\Column(length: 2048)]plus a corresponding migration).Severity
minor
Found by
Automated audit by Claude Code