Bug 2016640 (CVE-2020-27304)

Summary: CVE-2020-27304 civetweb: directory traversal when using the built-in example HTTP form-based file upload mechanism via the mg_handle_form_request API
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: amctagga, anharris, bniver, flucifre, gmeno, hvyas, mbenjamin, mhackett, osoukup, sfowler, sostapov, vereddy
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: CivetWeb 1.15 Doc Type: If docs needed, set a value
Doc Text:
A remote code execution vulnerability was found in CivetWeb (embeddable web server/library). Due to a directory traversal issue, an attacker is able to add or overwrite files that are subsequently executed which lead to impact to confidentiality, integrity, and availability of the application.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-12-01 17:52:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2020730, 2020740    
Bug Blocks: 2016641    

Description Guilherme de Almeida Suckevicz 2021-10-22 13:33:02 UTC
The CivetWeb web library does not validate uploaded filepaths when running on an OS other than Windows, when using the built-in HTTP form-based file upload mechanism, via the mg_handle_form_request API. Web applications that use the file upload form handler, and use parts of the user-controlled filename in the output path, are susceptible to directory traversal

Reference:
https://groups.google.com/g/civetweb/c/yPBxNXdGgJQ
https://jfrog.com/blog/cve-2020-27304-rce-via-directory-traversal-in-civetweb-http-server/

Comment 1 Przemyslaw Roguski 2021-11-02 16:14:20 UTC
Important to mention that this vulnerability does not affect component if at least one of these is true:
- You are using the pre-built Windows executable from SourceForge or GitHub releases (no CivetWeb version is affected)
- You are using "make" (for Linux) or "cmake" in the civetweb root directory to build the server on your own.
- You are building only using files from src/ and include/ but not examples/.
- You do not have html form handlers, that allow file upload.

Comment 4 errata-xmlrpc 2021-12-01 17:24:15 UTC
This issue has been addressed in the following products:

  RHACS-3.67-RHEL-8

Via RHSA-2021:4902 https://access.redhat.com/errata/RHSA-2021:4902

Comment 5 Product Security DevOps Team 2021-12-01 17:52:02 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2020-27304