forked from NVIDIA/NemoClaw
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 🛡️ Sentinel: [HIGH] Fix Weak Hashing Algorithm (SHA256 without salt) #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Hardonian
merged 3 commits into
main
from
jules-fix-credential-hash-7495761229841664717
May 29, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3ed4822
fix: 🛡️ Sentinel: [HIGH] Fix Weak Hashing Algorithm (SHA256 without s…
Hardonian 4d8ad9b
fix: 🛡️ Sentinel: [HIGH] Fix Weak Hashing Algorithm (SHA256 without s…
Hardonian 4cf7ac4
Merge branch 'main' into jules-fix-credential-hash-7495761229841664717
Hardonian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ## 2024-05-29 - [Insecure Temporary File Creation] | ||
| **Vulnerability:** Unsafe creation of temporary SSH config files with predictable names directly in `os.tmpdir()` (`/tmp`). | ||
| **Learning:** Using predictable file paths in shared directories like `/tmp` leaves the system vulnerable to symlink attacks or file hijacking, where an attacker can pre-create the file to gain unauthorized access or overwrite arbitrary files. | ||
| **Prevention:** Always use safe primitives like `fs.mkdtempSync` alongside `os.tmpdir()` to create a uniquely named, secure directory (`0700` permissions by default in Node.js) for placing sensitive temporary files. | ||
| ## 2024-05-24 - Weak Hashing Algorithm (SHA256 without salt) | ||
| **Vulnerability:** The codebase was obfuscating credentials and tokens using SHA-256 without a salt. These hashes were stored and used for state integrity checks and multi-sandbox conflict detection. | ||
| **Learning:** Pure string equality checks on hashes (`a === b`) for deterministic validation creates an implicit requirement for saltless, fast algorithms which naturally leads to weak hashing implementations. | ||
| **Prevention:** For secure operations, prefer Node.js built-ins (`scryptSync` + `timingSafeEqual`). When deterministic state comparison is necessary, it must not apply to secrets; secrets should always use randomized salts and dedicated verification routines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ## 🎯 What | ||
|
|
||
| The `hashCredential` function previously used an unsalted SHA-256 algorithm to hash credentials, which is insecure and vulnerable to rainbow table attacks and brute-forcing. | ||
|
|
||
| ## ⚠️ Risk | ||
|
|
||
| If an attacker gains access to the local sandbox state or the registry payload where these hashes are stored, they could rapidly compute plaintexts using hardware acceleration or pre-computed hash tables, compromising the messaging bridge tokens or router credentials. | ||
|
|
||
| ## 🛡️ Solution | ||
|
|
||
| - Migrated the hashing implementation to use Node.js's native `crypto.scryptSync` with a random 16-byte salt per hash. | ||
| - Implemented `verifyCredential` using `crypto.timingSafeEqual` to securely compare plaintexts against stored salted hashes. | ||
| - Retained a fallback in `verifyCredential` to support legacy, unsalted SHA-256 hashes for backwards compatibility with existing active deployments. | ||
| - Updated conflict detection logic to pass plaintexts safely for in-memory resolution where strict equality checks on hashes are mathematically impossible with distinct salts. | ||
|
|
||
| Signed-off-by: Jules <jules@nemo.claw> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| with open("scripts/verify-status-truth.ts", "r") as f: | ||
| content = f.read() | ||
|
|
||
| # Replace rg with find since rg is not available | ||
| target = "const rawFiles = execSync('rg --files src test docs .github/workflows scripts').toString('utf8').trim();" | ||
| replacement = "const rawFiles = execSync('find src test docs .github/workflows scripts -type f').toString('utf8').trim();" | ||
|
|
||
| content = content.replace(target, replacement) | ||
|
|
||
| with open("scripts/verify-status-truth.ts", "w") as f: | ||
| f.write(content) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.