Finding the input path
A normal request used a value such as pic=Zm94, which decodes to fox.
Encoding changes the representation of input, not its meaning. I tested the decoded value as a database input and found that SQL operators still reached the query.
Confirming SQL injection
I Base64-encoded a simple true condition:
' OR '1'='1
The response rendered every critter description instead of a single record. That showed the decoded value was being interpreted as SQL rather than compared as ordinary data.
Following the database
I used one-column UNION SELECT queries to follow the data:
version()identified MySQL 8.0.46.information_schema.tablesrevealed the application tables.information_schema.columnsrevealed the secret table’s columns.- Selecting its note field returned the challenge flag.
' UNION SELECT note FROM secret_vault --
The same value sent in pic was Base64-encoded and then URL-encoded for the request.
Impact and result
The public gallery endpoint allowed read-only SQL execution, schema enumeration, and access to data outside the intended animal records. Intigriti closed the challenge report as resolved at medium severity.
What should change?
- Use prepared statements with bound parameters for the gallery lookup.
- Allow only known critter identifiers after decoding.
- Give the gallery database account access only to the data it needs.
- Do not expose database errors or unrestricted query results.