Security review: fix traversal, identity, injection and takeover paths
CI / agent (push) Successful in 3s
CI / site (push) Successful in 2s
CI / go (push) Successful in 34s

Findings from a full review (auth/API, CA and rack channel, config
generation, integrations, UI/agents/scripts), each verified in code:

- rack binary endpoint read any region file via arch=../.. (CA key)
- render endpoint traversal; machine-reported MACs used as file paths
- delegated intermediates could mint admin/rack identities and IPs;
  identities now require root-issued certs, intermediates are
  ServerAuth-only with both name types constrained
- rack certs were ServerAuth for rack-chosen SANs: now client-only;
  racks accept only the region's own cert; join checks the CA
  fingerprint; unbound join codes cannot take an existing name; job
  results bound to the rack that took them
- rack self-update: region signs binaries with the CA key, the root
  unit verifies against the join-time CA in a root-owned dir
- dnsmasq reads a checked, root-owned copy limited to generated options
- commissioning could overwrite deployed machines; MAC takeover of PXE
- injection into dnsmasq/cloud-init/PXE/udev/DNS via names and
  machine-reported strings; stored XSS in the UI; CSP and cross-origin
  protection; deploy agent shell injection and seed traversal
- Redfish requests confined to the BMC's /redfish/ tree
- admin_http defaults to loopback; body limits and timeouts; secrets
  off command lines

Also: IPAM claim/reconcile race, sync stopping on one error, watchdog
race, release wiping the wrong disk, SAN LUNs as auto targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 17:58:42 +01:00
1 parent 6e4be736ec
commit a549f01ef5
28 files changed
+782 -154

No files matched your search

+29 -2
View File
@@ -154,8 +154,12 @@ func bmcHTTPClient(c *bmcCreds) *http.Client {
// bmcBase builds https://host[:port] from the record; IPMI's port is not Redfish's.
func bmcBase(c *bmcCreds, scheme string, defPort int) string {
a := strings.TrimRight(c.Address, "/")
if strings.Contains(a, "://") {
return a
if strings.Contains(a, "://") { // an operator's https://host:port: scheme and authority only
u, err := url.Parse(a)
if err != nil || (u.Scheme != "https" && u.Scheme != "http") || u.Host == "" || u.User != nil {
return "https://invalid.invalid"
}
return u.Scheme + "://" + u.Host
}
port := c.Port
if port == 623 || port == 0 {
@@ -175,12 +179,35 @@ func newRF(c *bmcCreds) *rfClient {
return &rfClient{base: bmcBase(c, "https", 443), user: c.User, pass: c.Password, hc: bmcHTTPClient(c)}
}
// resolve turns a path the BMC handed us (@odata.id, an action target, a task
// monitor) into one on this BMC. Vendors return relative paths, full URLs and
// trailing slashes; anything that would leave the BMC or the Redfish tree (and
// take the credentials with it) is refused.
func (r *rfClient) resolve(p string) (string, error) {
if strings.Contains(p, "://") {
u, err := url.Parse(p)
b, _ := url.Parse(r.base)
if err != nil || b == nil || !strings.EqualFold(u.Host, b.Host) || u.User != nil {
return "", fmt.Errorf("the BMC pointed at %q, which is not this BMC", p)
}
p = u.RequestURI()
}
if !strings.HasPrefix(p, "/redfish/") || strings.Contains(p, "/../") || strings.HasSuffix(p, "/..") {
return "", fmt.Errorf("the BMC pointed at %q, outside /redfish/", p)
}
return p, nil
}
func (r *rfClient) do(ctx context.Context, method, path string, body, out any) (int, error) {
var rd io.Reader
if body != nil {
b, _ := json.Marshal(body)
rd = bytes.NewReader(b)
}
path, err := r.resolve(path)
if err != nil {
return 0, err
}
req, err := http.NewRequestWithContext(ctx, method, r.base+path, rd)
if err != nil {
return 0, err