/sys/devices/virtual/powercap accessible by default to containers

Overview

Source
ID
GHSA-jq35-85cj-fj4p
Affected package

Description

Intel's RAPL (Running Average Power Limit) feature, introduced by the Sandy Bridge microarchitecture, provides software insights into hardware energy consumption. To facilitate this, Intel introduced the powercap framework in Linux kernel 3.13, which reads values via relevant MSRs (model specific registers) and provides unprivileged userspace access via `sysfs`. As RAPL is an interface to access a hardware feature, it is only available when running on bare metal with the module compiled into the kernel.

By 2019, it was realized that in some cases unprivileged access to RAPL readings could be exploited as a power-based side-channel against security features including AES-NI (potentially inside a SGX enclave) and KASLR (kernel address space layout randomization). Also known as the [PLATYPUS attack](https://platypusattack.com/), Intel assigned [CVE-2020-8694](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8694) and [CVE-2020-8695](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8695), and AMD assigned [CVE-2020-12912](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-12912).

Several mitigations were applied; Intel reduced the sampling resolution via a microcode update, and the Linux kernel [prevents access by non-root users](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=949dd0104c496fa7c14991a23c03c62e44637e71) since 5.10. However, this kernel-based mitigation does not apply to many container-based scenarios: * Unless using user namespaces, root inside a container has the same level of privilege as root outside the container, but with a slightly more narrow view of the system * `sysfs` is mounted inside containers read-only; however only read access is needed to carry out this attack on an unpatched CPU

While this is not a direct vulnerability in container runtimes, defense in depth and safe defaults are valuable and preferred, especially as this poses a risk to multi-tenant container environments running directly on affected hardware. This is provided by masking `/sys/devices/virtual/powercap` in the default mount configuration, and adding an additional set of rules to deny it in the default AppArmor profile.

While `sysfs` is not the only way to read from the RAPL subsystem, other ways of accessing it require additional capabilities such as `CAP_SYS_RAWIO` which is not available to containers by default, or `perf` paranoia level less than 1, which is a non-default kernel tunable.

## References

* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8694 * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-8695 * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-12912 * https://platypusattack.com/ * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=949dd0104c496fa7c14991a23c03c62e44637e71 * https://web.eece.maine.edu/~vweaver/projects/rapl/

Summary

19.04k
Total packages affected
Packages with at least one version that is affected by the advisory or has an affected dependency.
3.19k
Packages with a known fix
Packages with versions affected by the advisory that have a greater version that is not affected.
1.41%
Total ecosystem affected
The proportion of packages in the ecosystem that are affected by the advisory (fixed or not).
Affected Version: Introduced: 24.0.0, Fixed: 24.0.7, Introduced: 21.0.0, Fixed: 23.0.8, Introduced: 0, Fixed: 20.10.27
Patched/Unaffected
v20.10.27+incompatible
v23.0.8+incompatible
v23.0.9+incompatible
v23.0.10+incompatible
v23.0.14+incompatible
v23.0.15+incompatible
v23.0.16+incompatible
v24.0.7+incompatible
v24.0.8+incompatible
v24.0.9+incompatible
v25.0.0+incompatible
v25.0.1+incompatible
v25.0.2+incompatible
v25.0.3+incompatible
v25.0.5+incompatible
v25.0.7+incompatible
v26.0.0+incompatible
v27.1.2+incompatible
v27.2.0+incompatible
v27.2.1+incompatible
v27.3.0+incompatible
v27.3.1+incompatible
v27.4.0+incompatible
v27.4.1+incompatible
v27.5.0+incompatible
v27.5.1+incompatible
Affected
v24.0.6+incompatible
v24.0.5+incompatible
v24.0.0+incompatible
v23.0.7+incompatible
v23.0.5+incompatible
v23.0.4+incompatible
v23.0.1+incompatible
v20.10.26+incompatible
v20.10.22+incompatible
v20.10.21+incompatible
v20.10.20+incompatible
v20.10.19+incompatible
v20.10.12+incompatible
v20.10.11+incompatible
v20.10.10+incompatible
v20.10.9+incompatible
v20.10.8+incompatible
v20.10.6+incompatible
v20.10.5+incompatible
v20.10.4+incompatible
v20.10.3+incompatible
v20.10.2+incompatible
v20.10.1+incompatible
v20.10.0+incompatible
v1.13.1
v1.13.0
v1.12.6
v1.12.5
v1.12.4
v1.12.3
v1.12.2
v1.12.1
v1.12.0
v1.11.2
v1.11.1
v1.11.0
v1.10.3
v1.10.2
v1.10.1
v1.10.0
v1.9.1
v1.9.0
v1.8.3
v1.8.2
v1.8.1
v1.8.0
v1.7.1
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.0
v1.4.1
v1.4.0
v1.3.3
v1.3.2
v1.3.1
v1.3.0
v1.2.0
v1.1.2
v1.1.1
v1.1.0
v1.0.1
v1.0.0
v0.12.0
v0.11.1
v0.11.0
v0.10.0
v0.9.1
v0.9.0
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.7
v0.6.6
v0.6.5
v0.6.4
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.8
v0.4.7
v0.4.6
v0.4.5
v0.4.4
v0.4.3
v0.4.2
v0.4.1
v0.4.0
v0.3.4
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.2
v0.2.1
v0.2.0
v0.1.8
v0.1.7
v0.1.6
v0.1.5
v0.1.4
v0.1.3
v0.1.2
v0.1.1
v0.1.0