Skip to content

Commit 6034af2

Browse files
fix(daemon): warn when PILOT_REGISTRY/PILOT_BEACON env vars override compiled defaults (PILOT-236) (#173)
PILOT_REGISTRY and PILOT_BEACON env vars silently override compiled defaults at startup with no log entry or warning. An attacker who controls the daemon's environment can redirect registry/beacon to attacker-controlled endpoints, granting trust to an imposter network. This adds a slog.Warn log entry after logging setup when either env var overrides the compiled default, alerting the operator that the daemon is connecting to a non-default registry or beacon address. Closes PILOT-236
1 parent d89e69e commit 6034af2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

cmd/daemon/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ var version = "dev"
3838
func main() {
3939
configPath := flag.String("config", "", "path to config file (JSON)")
4040
registryDefault := "34.71.57.205:9000"
41+
registryFromEnv := false
4142
if v := os.Getenv("PILOT_REGISTRY"); v != "" {
4243
registryDefault = v
44+
registryFromEnv = true
4345
}
4446
beaconDefault := "34.71.57.205:9001"
47+
beaconFromEnv := false
4548
if v := os.Getenv("PILOT_BEACON"); v != "" {
4649
beaconDefault = v
50+
beaconFromEnv = true
4751
}
4852
registryAddr := flag.String("registry", registryDefault, "registry server address (or $PILOT_REGISTRY)")
4953
beaconAddr := flag.String("beacon", beaconDefault, "beacon server address (or $PILOT_BEACON)")
@@ -138,6 +142,13 @@ func main() {
138142

139143
logging.Setup(*logLevel, *logFormat)
140144

145+
if registryFromEnv {
146+
slog.Warn("PILOT_REGISTRY env var overrides compiled default — registry address redirected to " + *registryAddr + ". If this is unexpected, check the daemon's environment for tampering.")
147+
}
148+
if beaconFromEnv {
149+
slog.Warn("PILOT_BEACON env var overrides compiled default — beacon address redirected to " + *beaconAddr + ". If this is unexpected, check the daemon's environment for tampering.")
150+
}
151+
141152
d := daemon.New(daemon.Config{
142153
RegistryAddr: *registryAddr,
143154
BeaconAddr: *beaconAddr,

0 commit comments

Comments
 (0)