SQL exception in JSON format
When a username longer than 64 characters is submitted twice, the application returns a raw SQL exception instead of a friendly error message, revealing database details.
- Triaged in 25 hours
- Fixed in 4 months
- Disclosed after 2.8 years
Hi, I know this is not critical, just a design issue, but it will be better if it will not show up to the user as an error, maybe in log files readable to the www-user or to the root user in order to debug.
PoC:
- Create a user and confirm the password
- Capture the packet
- Replay the packet with a username bigger than 64 words in length two times in order to duplicate the user.
- Receiving error.
This is working only when the input for the username is bigger than 64 words. (65 needed.)
Example:
Request - POST http://172.16.1.68/nextcloud/index.php/settings/users/users HTTP/1.1 DATA: username=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&password=test123A
Response -
{"message":"An exception occurred while executing 'INSERT INTO `oc_users` ( `uid`, `password` ) VALUES( ?, ? )' with params [\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"1|$2y$10$gwzH19jqn8HveRpCb2haNurF7rycqsZeYYS7b1zPENnUInUyP35J2\"]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' for key 'PRIMARY'"}
Example:
Request - POST http://172.16.1.68/nextcloud/index.php/settings/users/users HTTP/1.1 DATA: username=aaaaaaa&password=test123A
Response -
{"message":"A user with that name already exists."}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application does not validate the username length before attempting a database insert, and it returns the raw database exception to the client instead of a generic error message.
Impact
An attacker could see database error details, which may help in further attacks, but the report notes this is not critical and only occurs with overly long usernames.
What the attacker needed
Ability to send HTTP requests; username longer than 64 characters
The fix
The application should validate username length and return a generic error message instead of exposing the raw SQL exception.
How it was found
- Create a user and confirm the password.
- Capture the packet.
- Replay the packet with a username longer than 64 characters, twice, to duplicate the user.
- Observe the SQL error in the response.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The application tries to save a new user to a database. If the username is too long, the database rejects it and the application shows the full database error to the user. This error reveals internal details like table names and SQL commands, which should normally be hidden.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.