Skip to content

Commit d45961b

Browse files
authored
resource: specify full path for ioreg command in Darwin host ID reader (#7818)
Use full path when calling `ioreg` to mitigate potential malicious code execution in case of [Path Interception](https://attack.mitre.org/techniques/T1574/007/). Note that path interception typically requires the attacker to influence the environment or place a malicious executable earlier in $PATH, which, in this context, generally implies the script itself would need to be introduced/uploaded (or otherwise placed/executed) in the target environment for the attacker’s substitute `ioreg` to be reached during execution. Reference: - https://cwe.mitre.org/data/definitions/426.html
1 parent 37aa18d commit d45961b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3232
- Fix bad log message when key-value pairs are dropped because of key duplication in `go.opentelemetry.io/otel/sdk/log`. (#7662)
3333
- Fix `DroppedAttributes` on `Record` in `go.opentelemetry.io/otel/sdk/log` to not count the non-attribute key-value pairs dropped because of key duplication. (#7662)
3434
- Fix `SetAttributes` on `Record` in `go.opentelemetry.io/otel/sdk/log` to not log that attributes are dropped when they are actually not dropped. (#7662)
35+
- `WithHostID` detector in `go.opentelemetry.io/otel/sdk/resource` to use full path for `ioreg` command on Darwin (macOS). (#7818)
3536
- Fix missing `request.GetBody` in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` to correctly handle HTTP2 GOAWAY frame. (#7794)
3637

3738
<!-- Released section -->

sdk/resource/host_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ type hostIDReaderDarwin struct {
5151
execCommand commandExecutor
5252
}
5353

54-
// read executes `ioreg -rd1 -c "IOPlatformExpertDevice"` and parses host id
54+
// read executes `/usr/sbin/ioreg -rd1 -c "IOPlatformExpertDevice"` and parses host id
5555
// from the IOPlatformUUID line. If the command fails or the uuid cannot be
5656
// parsed an error will be returned.
5757
func (r *hostIDReaderDarwin) read() (string, error) {
58-
result, err := r.execCommand("ioreg", "-rd1", "-c", "IOPlatformExpertDevice")
58+
result, err := r.execCommand("/usr/sbin/ioreg", "-rd1", "-c", "IOPlatformExpertDevice")
5959
if err != nil {
6060
return "", err
6161
}

0 commit comments

Comments
 (0)