open-telemetry / opentelemetry-collector-releases

OpenTelemetry Collector Official Releases
https://opentelemetry.io
Apache License 2.0
252 stars 163 forks source link

OTE-01-005 WP1: Linux Binary Hardening Recommendations #618

Open mx-psi opened 3 months ago

mx-psi commented 3 months ago

From the security audit:

Testing confirmed that the OpenTelemetry Collector Linux binaries do not leverage a number of compiler flags to mitigate potential memory corruption vulnerabilities, which is a common issue of all Golang-compiled binaries. As a result, the application remains unnecessarily prone to the associated risks. Linux binaries fail to leverage the following memory corruption prevention flags:

  • Stack canaries: This defense mechanism is used to detect and prevent exploits from overwriting the return address.
  • RELRO: This leaves the GOT section writable. Without the RELRO flag, buffer overflows on a global variable can overwrite GOT entries.
  • PIE: The Position Independent Executable (PIE) flag is a security mechanism that enables Address Space Layout Randomization (ASLR), which randomizes the location where system executables are loaded into memory.

Since we do not use CGO, I think this should be as easy as adding -buildmode=pie.

[!NOTE]
2024 OpenTelemetry security audit finding reference: OTE-01-005 WP1: Linux Binary Hardening Recommendations

jackgopack4 commented 1 month ago

seems like buildmode=pie doesn't necessarily do anything if CGO is disabled

mx-psi commented 4 weeks ago

@jackgopack4 I believe some platforms do support it and others do not (at least that's what I get from this comment: https://github.com/golang/go/issues/64875#issuecomment-1874249860 ). We could pass the option only in those platforms

jackgopack4 commented 3 weeks ago

@mx-psi you're right; the error message is exactly the same and only happens on unsupported platforms. will add conditional logic and test again.

mx-psi commented 2 weeks ago

I think the actual PR that fixes this is #726, reopening until we merge that one

jackgopack4 commented 2 weeks ago

apologies for the confusion