'use strict'; // Guard: a hall-of-fame vulnerability should be visible in Admin Panel → Problems // under the same name. // Run: node tests/hallOfFameProblemsCoverage.test.cjs // // CLAUDE.md: where a security fix DENIES an operation and the denial can be // attributed, an administrator must be able to see that somebody tried. The // mechanism is a key in models/lib/securityCategories.js whose `bleed` is the // hall-of-fame name, so Problems groups attempts the way the site names them and // an admin can go from one to the other. // // 66 vulnerabilities are listed on the site and 30 have a key today. The other 36 // predate the rule, and this suite does NOT pretend to have judged them: deciding // whether a given fix has anything to detect means reading that fix, and claiming // otherwise here would be worse than the gap. // // So it is a RATCHET. Every name must be one of: // // * KEYED - it has a catalog key, and attempts show in Problems; // * DELIBERATE - it has nothing to detect, with the reason recorded here; // * PENDING - it predates the rule and has not been looked at yet. // // A NEW vulnerability that is none of the three fails this test. The PENDING list // may shrink and must never grow: that is the whole mechanism. Working one off it // means either adding a key or moving it to DELIBERATE with a reason. const assert = require('assert'); const fs = require('fs'); const os = require('os'); const path = require('path'); const ROOT = path.join(__dirname, '..'); // The website is a sibling checkout (CLAUDE.md: ../w/wekan.fi), so this degrades // to a skip rather than failing on a machine that only has the app. const HOF = path.join(os.homedir(), 'repos', 'w', 'wekan.fi', 'hall-of-fame', 'index.html'); let passed = 0; function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); } // Nothing to detect, and why. A *Bleed belongs here when the fix changed what a // response CARRIED, or only takes effect at build time, so there is no attempt to // attribute - not merely when nobody has written the key yet. const DELIBERATE = { HashBleed: 'every call to that endpoint is a legitimate admin call; the fault was ' + 'in what the answer CARRIED, so a log line would fire on normal use and say ' + 'nothing about an attacker (GHSA-6qpx-x7vr-p9w6, and securityCategories.js ' + 'records the same reason)', HostnameBleed: 'the incomplete hostname regular expressions existed only in a ' + 'source-reading translation regression test over hardcoded examples; no ' + 'application request reaches it, so there is no runtime attempt to deny, ' + 'attribute or record (CodeQL alerts #435 and #436)', RouteBleed: 'the incomplete regular-expression escaping existed only in a source-reading ' + 'test over its own hardcoded route table; no application request reaches it, so there ' + 'is no runtime attempt to deny, attribute or record (CodeQL alert #434)', UserSearchBleed: 'the fix makes search punctuation literal and removes sensitive fields from ' + 'the response; legitimate searches reach the same path, so there is no denied attack-only ' + 'event to attribute without logging ordinary use', SubtaskExportBleed: 'the fix scopes internal export queries and changes only what a legitimate ' + 'export response carries; no request is denied, so logging exports would record ordinary use', ClaimBleed: 'the fix ignores service-owned fields while processing every legitimate OIDC login; ' + 'there is no reliable way to distinguish a malicious claim from an administrator mistakenly ' + 'whitelisting an identity field without logging ordinary logins', AvatarMimeBleed: 'the fix changes response headers for every avatar whose stored MIME type is browser-executable; ' + 'serving an existing avatar is legitimate use and does not identify who originally supplied its metadata, ' + 'so recording the download would log viewers rather than an attributable attack', LegacyAttachBleed: 'the fix changes response headers for legitimate legacy attachment downloads; the request ' + 'does not identify whether dangerous stored metadata was malicious, so logging it would record ordinary ' + 'viewers and misattribute an old upload as a current attack', }; // Predates the rule and has not been judged yet. May shrink; must never grow. const PENDING = [ 'AdminBleed', 'AnchorBleed', 'AuthBleed', 'AvatarBleed', 'BFLABleed', 'BypassBleed', 'CloneBleed', 'CrashBleed', 'DUEBleed', 'ExcelBleed', 'ExportBleed', 'FieldBleed', 'FollowBleed', 'FrameBleed', 'IdentityBleed', 'InvisibleBleed', 'LDAPBleed', 'LockoutBleed', 'MegaBleed', 'PassBleed', 'PatternBleed', 'ProxyBleed', 'RandomBleed', 'ReactionBleed', 'SnowBleed', 'SocialBleed', 'SortBleed', 'SpliceBleed', 'TokenBleed', 'TransitBleed', 'UserBleed', 'WebhookBleed', 'WhereBleed', 'ZipBleed', ]; const catalog = fs.readFileSync(path.join(ROOT, 'models/lib/securityCategories.js'), 'utf8'); const keyed = new Set([...catalog.matchAll(/bleed: '(\w+)'/g)].map(m => m[1])); const hallOfFameNames = () => { if (!fs.existsSync(HOF)) return null; const html = fs.readFileSync(HOF, 'utf8'); return [...new Set([...html.matchAll(/