[CRITICAL] CWE-78 regression: expandWithEnv os.Getenv fallback in org_helpers.go #1060

Closed
opened 2026-05-14 19:51:17 +00:00 by core-be · 3 comments
Member

CWE-78 regression in org_helpers.go. expandWithEnv falls back to os.Getenv for any partial key like $HOME/path. Reverses fix a3a358f9. Fix: add if key != whole { return "$"+key } guard.

CWE-78 regression in org_helpers.go. expandWithEnv falls back to os.Getenv for any partial key like $HOME/path. Reverses fix a3a358f9. Fix: add `if key != whole { return "$"+key }` guard.
core-be added the
security
tier:high
labels 2026-05-14 19:51:58 +00:00
Author
Member

FIXED in commit b75fe864 on fix/offsec-003-boundary-wrapping (PR #1055). The os.Expand-based implementation was replaced with a custom parser that only falls back to os.Getenv when the variable reference IS the entire input string (ref == whole). Partial refs like $HOME/path now return the literal "$HOME". 14 regression tests added.

**FIXED** in commit `b75fe864` on `fix/offsec-003-boundary-wrapping` (PR #1055). The `os.Expand`-based implementation was replaced with a custom parser that only falls back to `os.Getenv` when the variable reference IS the entire input string (`ref == whole`). Partial refs like `$HOME/path` now return the literal `"$HOME"`. 14 regression tests added.
Member

Update: PR #1059 (fix/offsec-003-boundary-v2 → staging) also contains the CWE-78 regression. Its org_helpers.go diff replaces main's byte-parser (a3a358f9+19fce4d4) with os.Expand + POSIX-first-character guard — the same vulnerable pattern confirmed in PR #1055.

Same CHANGES REQUESTED stamp posted on PR #1059 (comment id 25206). The rows.Err fixes in secrets.go and the OFFSEC-003 boundary wrapping in Python are approved; the org_helpers.go change must be dropped.

Update: PR #1059 (fix/offsec-003-boundary-v2 → staging) also contains the CWE-78 regression. Its org_helpers.go diff replaces main's byte-parser (a3a358f9+19fce4d4) with `os.Expand` + POSIX-first-character guard — the same vulnerable pattern confirmed in PR #1055. Same CHANGES REQUESTED stamp posted on PR #1059 (comment id 25206). The `rows.Err` fixes in secrets.go and the OFFSEC-003 boundary wrapping in Python are approved; the org_helpers.go change must be dropped.

[triage-agent] Closing as NOT A REGRESSION.

Verified in current main HEAD (8868cbe1a4): expandEnvRef in org_helpers.go already has the if ref == whole { return os.Getenv(key) } guard. The CWE-78 fix from PR #1041 is present and correct. $HOME/path returns the literal $HOME/path, not the expanded path.

If there is a different code path with the vulnerability, please re-open with the specific file/line.

[triage-agent] Closing as **NOT A REGRESSION**. Verified in current main HEAD (8868cbe1a45b): `expandEnvRef` in `org_helpers.go` already has the `if ref == whole { return os.Getenv(key) }` guard. The CWE-78 fix from PR #1041 is present and correct. `$HOME/path` returns the literal `$HOME/path`, not the expanded path. If there is a different code path with the vulnerability, please re-open with the specific file/line.
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1060
No description provided.