Commit 5cd6388
fix(security): validate UPSTREAM_DNS before shell interpolation (#1141)
## Summary
- Add IPv4 regex validation for `UPSTREAM_DNS` before it is interpolated
into the `docker exec kubectl patch` command (CWE-78, NVBUG 6009988)
- Without validation, a malicious `resolv.conf` entry could inject shell
metacharacters into the kubectl patch JSON payload
- Rejects anything that isn't a valid IPv4 dotted-quad, aborting with a
clear error
## Test plan
- [ ] `fix-coredns.sh` with valid DNS (e.g. `8.8.8.8`) — patches CoreDNS
normally
- [ ] `fix-coredns.sh` with no resolvable DNS — falls back to `8.8.8.8`,
passes validation
- [ ] Simulated bad `UPSTREAM_DNS='"; rm -rf /'` — rejected with error,
no execution
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Chores**
* Added validation for DNS upstream settings to prevent invalid values
from being applied.
* Added a precondition check for a required tooling dependency; the
script now fails fast with a clear error if it's missing.
* Improved how DNS configuration is constructed and applied to reduce
risk of malformed updates and restarts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Carlos Villela <[email protected]>1 parent 5ff0681 commit 5cd6388
1 file changed
+43
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
68 | 81 | | |
69 | 82 | | |
70 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
71 | 113 | | |
72 | 114 | | |
73 | 115 | | |
| |||
0 commit comments