fix: CSS selector injection via unsanitized minion ID in Utils.js - #933
Conversation
Automated security fix generated by OrbisAI Security
|
|
I analyzed your request and ran the commands, but no file changes were produced. This can happen when:
Could you provide more specific instructions about which files and lines to change? |
|
this is your pull request. the requested change does not make sense as it is only a change for |
… IDs The previous fix replaced +, /, and = all with _, which is non-injective: two different minion IDs could produce the same HTML element ID. Use RFC 4648 §5 base64url instead: + → -, / → _, = stripped. Since - and _ are never produced by btoa, the mapping is injective. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the detailed review @erwindon. I've addressed all four points: 1. PR title/description mismatch — Updated the title and description to accurately reflect that only 2. Stale comment — Removed the 3. Non-unique mapping — You're correct, replacing all three with 4. PoC — Added to the PR description: Old code: querySelector("#mPj4+") → SyntaxError (+ is CSS adjacent sibling combinator) The new implementation: return "m" + window.btoa(pMinionId).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); |
…ud warnings Replace three .replace(/regex/g, ...) calls with .replaceAll(string, ...) as suggested by the reviewer. SonarCloud flags /g-regex .replace() calls when replaceAll is available; string arguments make intent clearer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
much better! this is something we can work with. [you already dis this] Can you please fix the 3 SonarCloud findings? I'm aware that SaltGUI still has several uses of In general there is no need to describe the PR history in the PR-description as in paragraph "The original fix ...". That information can be found in the comments below it and in the commits. This function has another flaw. By using the non-unique prefix " FYI: In ES6, A much better solution would be when the function-call |
|
(I somehow unintentionally closed the PR so re-opened it) |
Suggested by reviewer: merge old and new comment text so the explanation of what btoa is is not lost. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Removed the PR-history paragraph from the description — agreed that belongs in the commit/comment history, not the summary. Also updated the comment on line 503 as suggested. |
|
|
I have a busy week ahead, at least the first few days of it, and I don't want to rush this. |
|
I've repeated the original issue by using minion name switched to this PR --> all OK |
|
@anupamme THX!! |






Summary
Fix CSS selector injection vulnerability in
saltgui/static/scripts/Utils.js.Vulnerability
saltgui/static/scripts/Utils.js(getIdFromMinionId)Root cause:
getIdFromMinionIduseswindow.btoa()to encode minion IDs into HTML element IDs. Standard base64 output can contain+,/, and=— all invalid in CSS identifier syntax. These IDs are then used directly inquerySelector("#" + Utils.getIdFromMinionId(pMinionId))calls across ~10 files.PoC
A Salt minion named
>>>(or any hostname whose bytes base64-encode to a string containing+) causes every panel that tries to look up that minion's DOM row to throw aSyntaxError, breaking rendering for that minion.Fix
Use base64url encoding (RFC 4648 §5), the standard encoding for identifiers:
+→-/→_=(padding) → strippedSince
-and_are never produced bybtoa, the mapping is injective — no two different minion IDs can produce the same HTML element ID.Changes
saltgui/static/scripts/Utils.js—getIdFromMinionIdupdated to use base64url encodingAll 20
querySelectorcall sites that usegetIdFromMinionId(across 10 files) are protected by this single change.Verification
+→-and/→_use distinct replacement characters