crypto-inventory 0.4.0: Swift and Kotlin detectors (CryptoKit, CommonCrypto, Security.framework, Android Keystore, Tink, OkHttp, the libsignal Swift and Android APIs), Apple and Android manifests; remediation recipes for Apache and HAProxy measured on real servers, HAProxy precondition fixed
This commit is contained in:
1 parent
e453c0c42d
commit
b6ed4d2b71
37 files changed
+1623
-82
No files matched your search
@@ -32,7 +32,30 @@ const MAVEN_GROUP = {
|
||||
'org.bouncycastle': 'Bouncy Castle: classical and post-quantum algorithms',
|
||||
'io.jsonwebtoken': 'JJWT: JWS HS*/RS*/ES*/PS*/EdDSA', 'com.nimbusds': 'Nimbus JOSE+JWT', 'com.auth0': 'java-jwt (if artifact is java-jwt)',
|
||||
'org.web3j': 'secp256k1 ECDSA accounts (web3j)', 'com.google.crypto.tink': 'Tink: AEAD, signatures, hybrid encryption', 'org.conscrypt': 'Conscrypt TLS provider',
|
||||
// 0.4.0 (2026-10-18, libsignal pentru Android/JVM si bibliotecile obisnuite ale unei aplicatii Android)
|
||||
'org.signal': 'libsignal: Curve25519 identity and prekeys (X3DH/PQXDH), Kyber prekeys, Double Ratchet, SPQR, sealed sender',
|
||||
'org.whispersystems': 'legacy Signal protocol libraries (Curve25519, Double Ratchet)',
|
||||
'org.mindrot': 'bcrypt password hashing (jbcrypt)', 'de.mkammerer': 'Argon2 password hashing (argon2-jvm)', 'com.lambdaworks': 'scrypt',
|
||||
'org.bitcoinj': 'secp256k1 ECDSA (bitcoinj)',
|
||||
};
|
||||
// Swift Package Manager (Package.swift) si CocoaPods (Podfile, *.podspec), 0.4.0: pachetele criptografice cunoscute, dupa calea depozitului
|
||||
// sau numele pachetului / pod-ului. Versiunea e CERINTA declarata (from:, exact:, '~> 1.8'), nu cea rezolvata din Package.resolved / Podfile.lock.
|
||||
const SWIFT_PKG = [
|
||||
[/(^|\/)apple\/swift-crypto$|^swift-crypto$|^Crypto$/i, 'swift-crypto: the CryptoKit API on every platform (AES-GCM, ChaChaPoly, SHA-2, HMAC, HKDF, P-256/384/521, Curve25519; RSA in _CryptoExtras)'],
|
||||
[/(^|\/)krzyzanowskim\/CryptoSwift$|^CryptoSwift$/i, 'CryptoSwift: AES, ChaCha20, Blowfish, RSA, SHA-2/3, MD5, SHA-1, HMAC, PBKDF2 (pure Swift)'],
|
||||
[/(^|\/)jedisct1\/swift-sodium$|^swift-sodium$|^Sodium$/i, 'swift-sodium (libsodium): X25519, Ed25519, XSalsa20/XChaCha20-Poly1305, Argon2, BLAKE2b'],
|
||||
[/(^|\/)signalapp\/libsignal(-client)?$|^LibSignalClient$/i, 'libsignal: Curve25519 identity and prekeys (X3DH/PQXDH), Kyber prekeys, Double Ratchet, SPQR, sealed sender'],
|
||||
[/(^|\/)apple\/swift-certificates$|^swift-certificates$|^X509$/i, 'X.509 certificates (swift-certificates)'],
|
||||
[/(^|\/)apple\/swift-nio-ssl$|^swift-nio-ssl$/i, 'TLS for SwiftNIO (BoringSSL)'],
|
||||
[/(^|\/)(GigaBitcoin\/secp256k1\.swift|21-DOT-DEV\/swift-secp256k1)$|^secp256k1(\.swift)?$/i, 'secp256k1 ECDSA/Schnorr'],
|
||||
[/(^|\/)(skywinder|web3swift-team)\/web3swift$|^web3swift$/i, 'secp256k1 ECDSA accounts and signatures (web3swift)'],
|
||||
[/(^|\/)airsidemobile\/JOSESwift$|^JOSESwift$/i, 'JWS/JWE (classical algorithms)'],
|
||||
[/(^|\/)TakeScoop\/SwiftyRSA$|^SwiftyRSA$/i, 'RSA'],
|
||||
[/(^|\/)datatheorem\/TrustKit$|^TrustKit$/i, 'certificate pinning (SPKI)'],
|
||||
[/(^|\/)krzyzanowskim\/OpenSSL$|^OpenSSL(-Universal)?$/i, 'OpenSSL'],
|
||||
[/(^|\/)tmthecoder\/Argon2Swift$|^Argon2Swift$/i, 'Argon2 password hashing'],
|
||||
];
|
||||
const swiftPachet = (cale, nume) => SWIFT_PKG.find(([re]) => (cale && re.test(cale)) || (nume && re.test(nume)));
|
||||
const GO = [
|
||||
[/^golang\.org\/x\/crypto$/, 'extended crypto: ssh, chacha20poly1305, curve25519, bcrypt, argon2'],
|
||||
[/^github\.com\/cloudflare\/circl$/, 'CIRCL: ML-KEM, ML-DSA, SLH-DSA, hybrid KEMs, classical curves'],
|
||||
@@ -61,18 +84,24 @@ const CARGO = [
|
||||
[/^(sodiumoxide|libsodium-sys|dryoc)$/, 'libsodium (NaCl): X25519, Ed25519, XSalsa20/XChaCha20-Poly1305, Argon2'],
|
||||
];
|
||||
|
||||
export const NUME_MANIFEST = /^(package\.json|requirements[\w.-]*\.txt|pyproject\.toml|pom\.xml|build\.gradle(\.kts)?|go\.mod|Cargo\.toml)$/;
|
||||
export const NUME_MANIFEST = /^(package\.json|requirements[\w.-]*\.txt|pyproject\.toml|pom\.xml|build\.gradle(\.kts)?|libs\.versions\.toml|go\.mod|Cargo\.toml|Package\.swift|Podfile|[\w.+-]+\.podspec)$/;
|
||||
|
||||
function lib(ecosistem, nume, versiune, ofera, pos, inceputuri, fisier) {
|
||||
const { line } = randul(inceputuri, pos);
|
||||
const purl = ecosistem === 'npm' ? `pkg:npm/${nume.startsWith('@') ? '%40' + nume.slice(1) : nume}${versiune && /^[\w.-]+$/.test(versiune) ? '@' + versiune : ''}`
|
||||
: ecosistem === 'pypi' ? `pkg:pypi/${nume}${versiune && /^[\w.-]+$/.test(versiune) ? '@' + versiune : ''}`
|
||||
: ecosistem === 'maven' ? `pkg:maven/${nume.replace(':', '/')}${versiune && /^[\w.-]+$/.test(versiune) ? '@' + versiune : ''}`
|
||||
: ecosistem === 'cargo' ? `pkg:cargo/${nume}${versiune && /^[\w.-]+$/.test(versiune) ? '@' + versiune : ''}`
|
||||
: `pkg:golang/${nume}${versiune ? '@' + versiune : ''}`;
|
||||
const v = versiune && /^[\w.-]+$/.test(versiune) ? '@' + versiune : '';
|
||||
const purl = ecosistem === 'npm' ? `pkg:npm/${nume.startsWith('@') ? '%40' + nume.slice(1) : nume}${v}`
|
||||
: ecosistem === 'pypi' ? `pkg:pypi/${nume}${v}`
|
||||
: ecosistem === 'maven' ? `pkg:maven/${nume.replace(':', '/')}${v}`
|
||||
: ecosistem === 'cargo' ? `pkg:cargo/${nume}${v}`
|
||||
: ecosistem === 'swift' ? `pkg:swift/${nume}${v}`
|
||||
: ecosistem === 'cocoapods' ? `pkg:cocoapods/${nume}${v}`
|
||||
: `pkg:golang/${nume}${versiune ? '@' + versiune : ''}`;
|
||||
return { file: fisier, line, ecosystem: ecosistem, name: nume, version: versiune || undefined, provides: ofera, purl };
|
||||
}
|
||||
|
||||
// versiunea dintr-o cerinta CocoaPods ('~> 1.8', '>= 2.0', '1.8.0')
|
||||
const versiunePod = (s) => (s ? s.replace(/^[~>=<\s]+/, '').trim() || undefined : undefined);
|
||||
|
||||
export function citesteManifest(text, numeFisier, rel) {
|
||||
const inceputuri = inceputuriDeRand(text);
|
||||
const r = [];
|
||||
@@ -128,11 +157,31 @@ export function citesteManifest(text, numeFisier, rel) {
|
||||
if (!ofera) continue;
|
||||
r.push(lib('maven', `${g[1]}:${a[1]}`, v && !/\$\{/.test(v[1]) ? v[1] : undefined, ofera, m.index + m[0].indexOf(a[0]), inceputuri, rel));
|
||||
}
|
||||
} else if (/^build\.gradle/.test(numeFisier)) {
|
||||
} else if (/^build\.gradle/.test(numeFisier) || numeFisier === 'libs.versions.toml') {
|
||||
// Groovy si Kotlin DSL ("group:artifact:version"), si catalogul de versiuni Gradle (module = "group:artifact", versiunea in alt camp)
|
||||
for (const m of text.matchAll(/["']([\w.-]+):([\w.-]+)(?::([\w.-]+))?["']/g)) {
|
||||
const ofera = MAVEN_GROUP[m[1]];
|
||||
if (ofera) r.push(lib('maven', `${m[1]}:${m[2]}`, m[3], ofera, m.index + 1, inceputuri, rel));
|
||||
}
|
||||
} else if (numeFisier === 'Package.swift') {
|
||||
// .package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"), .package(url: ..., exact: / .upToNextMajor(from: / "1.0.0"..<),
|
||||
// .package(name: "LibSignalClient", path: "../..")
|
||||
for (const m of text.matchAll(/\.package\s*\(([^()]*(?:\([^()]*\)[^()]*)*)\)/g)) {
|
||||
const a = m[1];
|
||||
const url = /\burl\s*:\s*"([^"]+)"/.exec(a);
|
||||
const nume = /\bname\s*:\s*"([^"]+)"/.exec(a);
|
||||
const cale = url ? url[1].replace(/^[a-z]+:\/\//i, '').replace(/^git@([^:]+):/, '$1/').replace(/\.git$/, '').replace(/\/+$/, '') : null;
|
||||
const intrare = swiftPachet(cale, nume ? nume[1] : (cale ? cale.split('/').pop() : null));
|
||||
if (!intrare) continue;
|
||||
const v = /\b(?:from|exact)\s*:\s*"([^"]+)"/.exec(a) || /\.upToNext(?:Major|Minor)\s*\(\s*from\s*:\s*"([^"]+)"/.exec(a) || /"([^"]+)"\s*\.\.[.<]/.exec(a);
|
||||
r.push(lib('swift', cale || nume[1], v ? v[1] : undefined, intrare[1], m.index + m[0].indexOf(url ? url[0] : nume[0]), inceputuri, rel));
|
||||
}
|
||||
} else if (numeFisier === 'Podfile' || /\.podspec$/.test(numeFisier)) {
|
||||
// pod 'CryptoSwift', '~> 1.8' / s.dependency 'CryptoSwift', '~> 1.8'
|
||||
for (const m of text.matchAll(/(?:^|\s)(?:pod|\w+\.dependency)\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/g)) {
|
||||
const intrare = swiftPachet(null, m[1].split('/')[0]);
|
||||
if (intrare) r.push(lib('cocoapods', m[1].split('/')[0], versiunePod(m[2]), intrare[1], m.index + m[0].indexOf(m[1]), inceputuri, rel));
|
||||
}
|
||||
} else if (numeFisier === 'go.mod') {
|
||||
let pos = 0;
|
||||
let inRequire = false;
|
||||
|
||||
Reference in new issue
Block a user