Foscam IP Video Camera CGIProxy.fcgi Change Username pureftpd.passwd Injection Vulnerability
The camera's username-change command writes the new username into the FTP password database without validating its characters. An authenticated administrator could inject extra characters into that file and thereby bypass the FTP server's chroot restriction.
Originally disclosed on Cisco Talos
An exploitable injection vulnerability exists in the web management interface used by the Foscam C1 Indoor HD Camera running application firmware 2.52.2.37. A specially crafted HTTP request can allow for a user to inject arbitrary characters in the pureftpd.passwd file during a username change, which in turn allows…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
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
The new username is concatenated into the pureftpd.passwd line with snprintf without any validation or escaping of special characters.
Impact
An authenticated administrator could inject arbitrary characters into the FTP password database, which in turn allows bypassing chroot restrictions in the FTP server.
What the attacker needed
Administrator (privilege 2) account; network access to the camera's web interface
How it was found
- Send an HTTP request to the camera's CGIProxy.fcgi service invoking the changeUserName command with the usrName, newUsrName, usr and callbackJson parameters.
- Authenticate as a user with administrator privilege (privilege 2).
- The service extracts the parameters and calls changeAccountUsername.
- The function reads the whole pureftpd.passwd file and locates the line for the old username.
- It rebuilds the line with the unvalidated new username and runs pure-pw mkdb to apply the change.
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 camera keeps a list of FTP users in a text file, one line per user. When an administrator renames a user, the camera pastes the new name straight into that file without checking it. By putting special characters in the name, an attacker can add extra fields to the line, which the FTP server then trusts, letting them escape the folder they are normally locked into.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.