Skip to content

XSS with user-uploaded files

Moderate
Philip-Larsen-Donnelly published GHSA-763w-rm78-6xcg Dec 8, 2022

Package

dhis2-core (none)

Affected versions

2.35,2.36,2.37,2.38,2.39

Patched versions

2.36.12.1, 2.37.8.1, 2.38.2.1, 2.39.0.1

Description

Impact

Through various features of DHIS2, an authenticated user may be able to upload a file which includes embedded javascript. The user could then potentially trick another authenticated user to open the malicious file in a browser which would trigger the javascript code, resulting in a cross-site scripting (XSS) attack.

Patches

DHIS2 administrators should upgrade to the following hotfix releases:

  • 2.36.12.1
  • 2.37.8.1
  • 2.38.2.1
  • 2.39.0.1

Workarounds

Add the following simple CSP rule in your web proxy to the vulnerable endpoints: script-src 'none'

If you're using nginx, you can apply the following code to your DHIS2 location (usually under /etc/nginx/upstream):

location ~ (/documents/|/fileResources/[0-9a-zA-Z]+/data|/events/files|/dataValues/files|/externalFileResources/|/trackedEntityInstances/[0-9a-zA-Z]+/[0-9a-zA-Z]+/image|/messageConversations/[0-9a-zA-Z]+/[0-9a-zA-Z]+/attachments/) {
  add_header Content-Security-Policy "script-src 'none' ;" always;
  proxy_pass                http://<ip-of-DHIS2>:<port>;
}

Replace the <ip-of-DHIS2-instance>:<port> with the IP and port of the server or container running DHIS2 only.
Then restart nginx.

For Apache, assuming it's already configured as reverse proxy, you have to enable the headers module:

$ sudo a2enmod headers

Then add the following in your default website configuration:

<Location  ~ "(/documents/|/fileResources/[0-9a-zA-Z]+/data|/events/files|/dataValues/files|/externalFileResources/|/trackedEntityInstances/[0-9a-zA-Z]+/[0-9a-zA-Z]+/image/messageConversations/[0-9a-zA-Z]+/[0-9a-zA-Z]+/attachments/)" >
    Header set Content-Security-Policy "script-src 'none';"
</Location>

Restart apache.

References

For more information

If you have any questions or comments about this advisory, email us at [email protected]

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N

CVE ID

CVE-2022-41947

Weaknesses