xploitscan-shared-rules 2.4.17 → 2.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -165,7 +165,7 @@ interface CustomRule {
165
165
  * before a scan can be saved without enough provenance to explain a changed
166
166
  * grade.
167
167
  */
168
- declare const SCANNER_VERSION = "2.4.17";
168
+ declare const SCANNER_VERSION = "2.4.18";
169
169
 
170
170
  /**
171
171
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
package/dist/index.d.ts CHANGED
@@ -165,7 +165,7 @@ interface CustomRule {
165
165
  * before a scan can be saved without enough provenance to explain a changed
166
166
  * grade.
167
167
  */
168
- declare const SCANNER_VERSION = "2.4.17";
168
+ declare const SCANNER_VERSION = "2.4.18";
169
169
 
170
170
  /**
171
171
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SCANNER_VERSION = "2.4.17";
2
+ var SCANNER_VERSION = "2.4.18";
3
3
 
4
4
  // src/snippet.ts
5
5
  var cacheContent = null;
@@ -6316,8 +6316,183 @@ var CONFIG_CHECKS = [
6316
6316
  }
6317
6317
  return null;
6318
6318
  }
6319
+ },
6320
+ {
6321
+ id: "CFG013",
6322
+ title: "PHP base image affected by CVE-2026-109618 and CVE-2026-109619",
6323
+ severity: "critical",
6324
+ category: "Dependencies",
6325
+ description: "This Dockerfile builds on an official php image whose PHP version is affected by CVE-2026-109618 and CVE-2026-109619 (publicly known as PHP2Shell), memory-safety flaws reachable from unauthenticated HTTP requests to mod_php (-apache) and PHP-FPM (-fpm). Affected: 8.2.0-8.2.34, 8.3.0-8.3.35, 8.4.0-8.4.26, 8.5.0-8.5.11, and all end-of-life releases (8.1 and older), which have no fixed official release. Advisories: https://github.com/php/php-src/security/advisories/GHSA-w8hw-w9fx-j79w and https://github.com/php/php-src/security/advisories/GHSA-6wmf-4rv5-p3rp",
6326
+ fix: "Rebuild on php 8.2.35, 8.3.36, 8.4.27 or 8.5.12 or later, keeping the same variant (for example php:8.3.36-apache). End-of-life branches (8.1 and older) have no fixed release: move to a supported branch. Until you can rebuild, setting session.upload_progress.enabled=0, a low post_max_size and, on 8.5, fatal_error_backtraces=0 reduces but does not remove exposure.",
6327
+ owasp: "A06:2021",
6328
+ cwe: "CWE-1395",
6329
+ filePattern: /Dockerfile$/i,
6330
+ check(content) {
6331
+ const line = php2shellLines(content).cfg013Line;
6332
+ if (line === null) return null;
6333
+ return { line, snippet: getSnippet4(content, line) };
6334
+ }
6335
+ },
6336
+ {
6337
+ id: "CFG014",
6338
+ title: "PHP base image (non-web variant) at a version affected by CVE-2026-109618 and CVE-2026-109619",
6339
+ severity: "info",
6340
+ category: "Dependencies",
6341
+ description: "The final stage uses an official php image without the -apache or -fpm variant at an affected PHP version (8.2.0-8.2.34, 8.3.0-8.3.35, 8.4.0-8.4.26, 8.5.0-8.5.11, or 8.1 and older). The PHP advisories scope the risk to PHP serving web requests (mod_php, PHP-FPM, php-cgi, FrankenPHP, LiteSpeed); the official cli and zts images include php-cgi. Advisories: https://github.com/php/php-src/security/advisories/GHSA-w8hw-w9fx-j79w and https://github.com/php/php-src/security/advisories/GHSA-6wmf-4rv5-p3rp",
6342
+ fix: "Pin a fixed version (8.2.35, 8.3.36, 8.4.27, 8.5.12 or later). If this image never serves web requests, upgrade on your normal schedule.",
6343
+ owasp: "A06:2021",
6344
+ cwe: "CWE-1395",
6345
+ filePattern: /Dockerfile$/i,
6346
+ check(content) {
6347
+ const line = php2shellLines(content).cfg014Line;
6348
+ if (line === null) return null;
6349
+ return { line, snippet: getSnippet4(content, line) };
6350
+ }
6319
6351
  }
6320
6352
  ];
6353
+ var PHP2SHELL_LINE_LIMIT = 4096;
6354
+ var PHP2SHELL_FROM_CAP = 256;
6355
+ var PHP2SHELL_FROM_MARK = /^[ \t\uFEFF]{0,4096}FROM[ \t]/i;
6356
+ var PHP2SHELL_FROM = /^[ \t\uFEFF]{0,4096}FROM[ \t]{1,4096}(?:--[^ \t]{1,256}[ \t]{1,4096}){0,4}([^ \t]{1,512})(?:[ \t]{1,4096}AS[ \t]{1,4096}([^ \t]{1,128}))?[ \t]{0,4096}$/i;
6357
+ var PHP2SHELL_ARG = /^[ \t\uFEFF]{0,4096}ARG[ \t]{1,4096}([A-Za-z_][A-Za-z0-9_]{0,63})=(?:"([^"\s$]{1,64})"|'([^'\s$]{1,64})'|([^\s"'$]{1,64}))[ \t]{0,4096}$/i;
6358
+ var PHP2SHELL_VAR = /\$(?:\{([A-Za-z_][A-Za-z0-9_]{0,63})\}|([A-Za-z_][A-Za-z0-9_]{0,63}))/g;
6359
+ var PHP2SHELL_IMAGE = /^(?:(?:docker\.io|registry-1\.docker\.io|index\.docker\.io|mirror\.gcr\.io|public\.ecr\.aws\/docker)\/)?(?:library\/)?php(?::([A-Za-z0-9_][A-Za-z0-9_.-]{0,127}))?(?:@sha256:[a-f0-9]{64})?$/;
6360
+ var PHP2SHELL_TAG = /^(\d{1,2})(?:\.(\d{1,2}))?(?:\.(\d{1,3}))?(?:-([a-z0-9][a-z0-9.-]{0,63}))?$/;
6361
+ var PHP2SHELL_FIXED_PATCH = [
6362
+ [8, 2, 35],
6363
+ [8, 3, 36],
6364
+ [8, 4, 27],
6365
+ [8, 5, 12]
6366
+ ];
6367
+ function php2shellDigits(value) {
6368
+ let n = 0;
6369
+ for (let i = 0; i < value.length; i++) n = n * 10 + (value.charCodeAt(i) - 48);
6370
+ return n;
6371
+ }
6372
+ function php2shellFixedPatch(major, minor) {
6373
+ for (let i = 0; i < PHP2SHELL_FIXED_PATCH.length; i++) {
6374
+ const row = PHP2SHELL_FIXED_PATCH[i];
6375
+ if (row[0] === major && row[1] === minor) return row[2];
6376
+ }
6377
+ return null;
6378
+ }
6379
+ function php2shellAffected(major, minor, patch) {
6380
+ if (major < 8) return true;
6381
+ if (major === 8 && minor !== null && minor <= 1) return true;
6382
+ if (minor === null || patch === null) return false;
6383
+ const fixed = php2shellFixedPatch(major, minor);
6384
+ return fixed !== null && patch < fixed;
6385
+ }
6386
+ function php2shellWebSapi(suffix) {
6387
+ if (!suffix) return false;
6388
+ let start = 0;
6389
+ for (let i = 0; i <= suffix.length; i++) {
6390
+ if (i === suffix.length || suffix.charCodeAt(i) === 45) {
6391
+ const token = suffix.slice(start, i);
6392
+ if (token === "apache" || token === "fpm") return true;
6393
+ start = i + 1;
6394
+ }
6395
+ }
6396
+ return false;
6397
+ }
6398
+ function php2shellComment(line) {
6399
+ let i = 0;
6400
+ while (i < line.length) {
6401
+ const c = line.charCodeAt(i);
6402
+ if (c !== 32 && c !== 9) break;
6403
+ i += 1;
6404
+ }
6405
+ return i < line.length && line.charCodeAt(i) === 35;
6406
+ }
6407
+ function php2shellNormalize(raw, index) {
6408
+ let line = raw;
6409
+ if (index === 0 && line.charCodeAt(0) === 65279) line = line.slice(1);
6410
+ if (line.length > 0 && line.charCodeAt(line.length - 1) === 13) line = line.slice(0, -1);
6411
+ return line;
6412
+ }
6413
+ function php2shellSubstitute(ref, args) {
6414
+ PHP2SHELL_VAR.lastIndex = 0;
6415
+ let unknown = false;
6416
+ const out = ref.replace(PHP2SHELL_VAR, (match, braced, bare) => {
6417
+ const name = braced ?? bare;
6418
+ const value = name ? args.get(name) : void 0;
6419
+ if (value === void 0) {
6420
+ unknown = true;
6421
+ return match;
6422
+ }
6423
+ return value;
6424
+ });
6425
+ if (unknown || out.includes("$")) return null;
6426
+ return out;
6427
+ }
6428
+ function php2shellLines(content) {
6429
+ const args = /* @__PURE__ */ new Map();
6430
+ const stages = /* @__PURE__ */ new Set();
6431
+ let seenFrom = false;
6432
+ let fromCount = 0;
6433
+ let capped = false;
6434
+ let cfg013Line = null;
6435
+ let lastLine = 0;
6436
+ let lastAffectedNonWeb = false;
6437
+ const lines = content.split("\n");
6438
+ for (let i = 0; i < lines.length; i++) {
6439
+ const line = php2shellNormalize(lines[i] ?? "", i);
6440
+ if (line.length > PHP2SHELL_LINE_LIMIT) continue;
6441
+ if (php2shellComment(line)) continue;
6442
+ if (!seenFrom) {
6443
+ const arg = PHP2SHELL_ARG.exec(line);
6444
+ if (arg?.[1]) {
6445
+ const value = arg[2] ?? arg[3] ?? arg[4];
6446
+ if (value !== void 0) {
6447
+ args.set(arg[1], value);
6448
+ continue;
6449
+ }
6450
+ }
6451
+ }
6452
+ if (!PHP2SHELL_FROM_MARK.test(line)) continue;
6453
+ fromCount += 1;
6454
+ if (fromCount > PHP2SHELL_FROM_CAP) {
6455
+ capped = true;
6456
+ break;
6457
+ }
6458
+ seenFrom = true;
6459
+ const lineNo = i + 1;
6460
+ lastLine = lineNo;
6461
+ lastAffectedNonWeb = false;
6462
+ const from = PHP2SHELL_FROM.exec(line);
6463
+ const rawRef = from?.[1];
6464
+ if (!rawRef) continue;
6465
+ const ref = php2shellSubstitute(rawRef, args);
6466
+ if (ref === null) continue;
6467
+ const asName = from?.[2];
6468
+ const refLower = ref.toLowerCase();
6469
+ if (stages.has(refLower)) {
6470
+ if (asName) stages.add(asName.toLowerCase());
6471
+ continue;
6472
+ }
6473
+ if (asName) stages.add(asName.toLowerCase());
6474
+ if (ref === "scratch") continue;
6475
+ const image = PHP2SHELL_IMAGE.exec(ref);
6476
+ const tag = image?.[1];
6477
+ if (!image || tag === void 0 || tag === "latest") continue;
6478
+ const parsed = PHP2SHELL_TAG.exec(tag);
6479
+ const majorText = parsed?.[1];
6480
+ if (!parsed || majorText === void 0) continue;
6481
+ const major = php2shellDigits(majorText);
6482
+ const minor = parsed[2] !== void 0 ? php2shellDigits(parsed[2]) : null;
6483
+ const patch = parsed[3] !== void 0 ? php2shellDigits(parsed[3]) : null;
6484
+ if (!php2shellAffected(major, minor, patch)) continue;
6485
+ if (php2shellWebSapi(parsed[4])) {
6486
+ if (cfg013Line === null) cfg013Line = lineNo;
6487
+ } else {
6488
+ lastAffectedNonWeb = true;
6489
+ }
6490
+ }
6491
+ return {
6492
+ cfg013Line,
6493
+ cfg014Line: !capped && cfg013Line === null && lastAffectedNonWeb ? lastLine : null
6494
+ };
6495
+ }
6321
6496
  function scanConfigs(files) {
6322
6497
  const findings = [];
6323
6498
  for (const { path: filePath, content } of files) {