Remote Code Execution Through Image Uploads in BookStack
The advisory, in context
Impact
A user could upload PHP files through image upload functions, which would allow them to execute code on the host system remotely. They would then have the permissions of the PHP process.
This most impacts scenarios where non-trusted users are given permission to upload images in any area of the application.
Patches
The issue was addressed in a series of patches: v0.25.3, v0.25.4 and v0.25.5. Users should upgrade to at least v0.25.5 to avoid this patch but ideally the latest BookStack version as previous versions are un-supported.
Workarounds
Depending on BookStack version, you could use the local_secure image storage option, or use s3 or a similar compatible service.
Preventing direct execution of any php files, apart from the public/index.php file, though web-server configuration would also prevent this.
References
BookStack Beta v0.25.3 BookStack Beta v0.25.4 BookStack Beta v0.25.5
For more information
If you have any questions or comments about this advisory:
- Open an issue in the BookStack GitHub repository.
- Ask on the BookStack Discord chat.
- Follow the BookStack Security advise to contact someone privately.
Affected packages
Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.
Earlier releases before 0.25.5
Fixed in 0.25.5
69 explicitly affected versions
0.7.2, V0.7.5, v0.10.0, v0.11.0, v0.11.1, v0.11.2, v0.12.0, v0.12.1, v0.12.2, v0.13.0, v0.13.1, v0.14.0, v0.14.1, v0.14.2, v0.14.3, v0.15.0, v0.15.1, v0.15.2, v0.15.3, v0.16.0, v0.16.1, v0.16.2, v0.16.3, v0.17.0, v0.17.1, v0.17.2, v0.17.3, v0.17.4, v0.18.0, v0.18.1, v0.18.2, v0.18.3, v0.18.4, v0.18.5, v0.19.0, v0.20.0, v0.20.1, v0.20.2, v0.20.3, v0.21.0, v0.22.0, v0.23.0, v0.23.1, v0.23.2, v0.24.0, v0.24.1, v0.24.2, v0.24.3, v0.25.0, v0.25.1, v0.25.2, v0.25.3, v0.25.4, v0.5.0, v0.6.0, v0.6.1, v0.6.2, v0.6.3, v0.7.0, v0.7.3, v0.7.4, v0.7.6, v0.8.0, v0.8.1, v0.8.2, v0.9.0, v0.9.1, v0.9.2, v0.9.3
View affected-version evidence
{
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.25.5"
}
],
"type": "ECOSYSTEM"
}
],
"versions": [
"0.7.2",
"V0.7.5",
"v0.10.0",
"v0.11.0",
"v0.11.1",
"v0.11.2",
"v0.12.0",
"v0.12.1",
"v0.12.2",
"v0.13.0",
"v0.13.1",
"v0.14.0",
"v0.14.1",
"v0.14.2",
"v0.14.3",
"v0.15.0",
"v0.15.1",
"v0.15.2",
"v0.15.3",
"v0.16.0",
"v0.16.1",
"v0.16.2",
"v0.16.3",
"v0.17.0",
"v0.17.1",
"v0.17.2",
"v0.17.3",
"v0.17.4",
"v0.18.0",
"v0.18.1",
"v0.18.2",
"v0.18.3",
"v0.18.4",
"v0.18.5",
"v0.19.0",
"v0.20.0",
"v0.20.1",
"v0.20.2",
"v0.20.3",
"v0.21.0",
"v0.22.0",
"v0.23.0",
"v0.23.1",
"v0.23.2",
"v0.24.0",
"v0.24.1",
"v0.24.2",
"v0.24.3",
"v0.25.0",
"v0.25.1",
"v0.25.2",
"v0.25.3",
"v0.25.4",
"v0.5.0",
"v0.6.0",
"v0.6.1",
"v0.6.2",
"v0.6.3",
"v0.7.0",
"v0.7.3",
"v0.7.4",
"v0.7.6",
"v0.8.0",
"v0.8.1",
"v0.8.2",
"v0.9.0",
"v0.9.1",
"v0.9.2",
"v0.9.3"
]
}References
- https://github.com/BookStackApp/BookStack/security/advisories/GHSA-g9rq-x4fj-f5hx
- https://nvd.nist.gov/vuln/detail/CVE-2020-5256
- https://github.com/BookStackApp/BookStack/releases/tag/v0.25.3
- https://github.com/BookStackApp/BookStack/releases/tag/v0.25.4
- https://github.com/BookStackApp/BookStack/releases/tag/v0.25.5