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.cjs CHANGED
@@ -162,7 +162,7 @@ __export(index_exports, {
162
162
  module.exports = __toCommonJS(index_exports);
163
163
 
164
164
  // src/version.ts
165
- var SCANNER_VERSION = "2.4.17";
165
+ var SCANNER_VERSION = "2.4.18";
166
166
 
167
167
  // src/snippet.ts
168
168
  var cacheContent = null;
@@ -6479,8 +6479,183 @@ var CONFIG_CHECKS = [
6479
6479
  }
6480
6480
  return null;
6481
6481
  }
6482
+ },
6483
+ {
6484
+ id: "CFG013",
6485
+ title: "PHP base image affected by CVE-2026-109618 and CVE-2026-109619",
6486
+ severity: "critical",
6487
+ category: "Dependencies",
6488
+ 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",
6489
+ 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.",
6490
+ owasp: "A06:2021",
6491
+ cwe: "CWE-1395",
6492
+ filePattern: /Dockerfile$/i,
6493
+ check(content) {
6494
+ const line = php2shellLines(content).cfg013Line;
6495
+ if (line === null) return null;
6496
+ return { line, snippet: getSnippet4(content, line) };
6497
+ }
6498
+ },
6499
+ {
6500
+ id: "CFG014",
6501
+ title: "PHP base image (non-web variant) at a version affected by CVE-2026-109618 and CVE-2026-109619",
6502
+ severity: "info",
6503
+ category: "Dependencies",
6504
+ 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",
6505
+ 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.",
6506
+ owasp: "A06:2021",
6507
+ cwe: "CWE-1395",
6508
+ filePattern: /Dockerfile$/i,
6509
+ check(content) {
6510
+ const line = php2shellLines(content).cfg014Line;
6511
+ if (line === null) return null;
6512
+ return { line, snippet: getSnippet4(content, line) };
6513
+ }
6482
6514
  }
6483
6515
  ];
6516
+ var PHP2SHELL_LINE_LIMIT = 4096;
6517
+ var PHP2SHELL_FROM_CAP = 256;
6518
+ var PHP2SHELL_FROM_MARK = /^[ \t\uFEFF]{0,4096}FROM[ \t]/i;
6519
+ 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;
6520
+ 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;
6521
+ var PHP2SHELL_VAR = /\$(?:\{([A-Za-z_][A-Za-z0-9_]{0,63})\}|([A-Za-z_][A-Za-z0-9_]{0,63}))/g;
6522
+ 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})?$/;
6523
+ var PHP2SHELL_TAG = /^(\d{1,2})(?:\.(\d{1,2}))?(?:\.(\d{1,3}))?(?:-([a-z0-9][a-z0-9.-]{0,63}))?$/;
6524
+ var PHP2SHELL_FIXED_PATCH = [
6525
+ [8, 2, 35],
6526
+ [8, 3, 36],
6527
+ [8, 4, 27],
6528
+ [8, 5, 12]
6529
+ ];
6530
+ function php2shellDigits(value) {
6531
+ let n = 0;
6532
+ for (let i = 0; i < value.length; i++) n = n * 10 + (value.charCodeAt(i) - 48);
6533
+ return n;
6534
+ }
6535
+ function php2shellFixedPatch(major, minor) {
6536
+ for (let i = 0; i < PHP2SHELL_FIXED_PATCH.length; i++) {
6537
+ const row = PHP2SHELL_FIXED_PATCH[i];
6538
+ if (row[0] === major && row[1] === minor) return row[2];
6539
+ }
6540
+ return null;
6541
+ }
6542
+ function php2shellAffected(major, minor, patch) {
6543
+ if (major < 8) return true;
6544
+ if (major === 8 && minor !== null && minor <= 1) return true;
6545
+ if (minor === null || patch === null) return false;
6546
+ const fixed = php2shellFixedPatch(major, minor);
6547
+ return fixed !== null && patch < fixed;
6548
+ }
6549
+ function php2shellWebSapi(suffix) {
6550
+ if (!suffix) return false;
6551
+ let start = 0;
6552
+ for (let i = 0; i <= suffix.length; i++) {
6553
+ if (i === suffix.length || suffix.charCodeAt(i) === 45) {
6554
+ const token = suffix.slice(start, i);
6555
+ if (token === "apache" || token === "fpm") return true;
6556
+ start = i + 1;
6557
+ }
6558
+ }
6559
+ return false;
6560
+ }
6561
+ function php2shellComment(line) {
6562
+ let i = 0;
6563
+ while (i < line.length) {
6564
+ const c = line.charCodeAt(i);
6565
+ if (c !== 32 && c !== 9) break;
6566
+ i += 1;
6567
+ }
6568
+ return i < line.length && line.charCodeAt(i) === 35;
6569
+ }
6570
+ function php2shellNormalize(raw, index) {
6571
+ let line = raw;
6572
+ if (index === 0 && line.charCodeAt(0) === 65279) line = line.slice(1);
6573
+ if (line.length > 0 && line.charCodeAt(line.length - 1) === 13) line = line.slice(0, -1);
6574
+ return line;
6575
+ }
6576
+ function php2shellSubstitute(ref, args) {
6577
+ PHP2SHELL_VAR.lastIndex = 0;
6578
+ let unknown = false;
6579
+ const out = ref.replace(PHP2SHELL_VAR, (match, braced, bare) => {
6580
+ const name = braced ?? bare;
6581
+ const value = name ? args.get(name) : void 0;
6582
+ if (value === void 0) {
6583
+ unknown = true;
6584
+ return match;
6585
+ }
6586
+ return value;
6587
+ });
6588
+ if (unknown || out.includes("$")) return null;
6589
+ return out;
6590
+ }
6591
+ function php2shellLines(content) {
6592
+ const args = /* @__PURE__ */ new Map();
6593
+ const stages = /* @__PURE__ */ new Set();
6594
+ let seenFrom = false;
6595
+ let fromCount = 0;
6596
+ let capped = false;
6597
+ let cfg013Line = null;
6598
+ let lastLine = 0;
6599
+ let lastAffectedNonWeb = false;
6600
+ const lines = content.split("\n");
6601
+ for (let i = 0; i < lines.length; i++) {
6602
+ const line = php2shellNormalize(lines[i] ?? "", i);
6603
+ if (line.length > PHP2SHELL_LINE_LIMIT) continue;
6604
+ if (php2shellComment(line)) continue;
6605
+ if (!seenFrom) {
6606
+ const arg = PHP2SHELL_ARG.exec(line);
6607
+ if (arg?.[1]) {
6608
+ const value = arg[2] ?? arg[3] ?? arg[4];
6609
+ if (value !== void 0) {
6610
+ args.set(arg[1], value);
6611
+ continue;
6612
+ }
6613
+ }
6614
+ }
6615
+ if (!PHP2SHELL_FROM_MARK.test(line)) continue;
6616
+ fromCount += 1;
6617
+ if (fromCount > PHP2SHELL_FROM_CAP) {
6618
+ capped = true;
6619
+ break;
6620
+ }
6621
+ seenFrom = true;
6622
+ const lineNo = i + 1;
6623
+ lastLine = lineNo;
6624
+ lastAffectedNonWeb = false;
6625
+ const from = PHP2SHELL_FROM.exec(line);
6626
+ const rawRef = from?.[1];
6627
+ if (!rawRef) continue;
6628
+ const ref = php2shellSubstitute(rawRef, args);
6629
+ if (ref === null) continue;
6630
+ const asName = from?.[2];
6631
+ const refLower = ref.toLowerCase();
6632
+ if (stages.has(refLower)) {
6633
+ if (asName) stages.add(asName.toLowerCase());
6634
+ continue;
6635
+ }
6636
+ if (asName) stages.add(asName.toLowerCase());
6637
+ if (ref === "scratch") continue;
6638
+ const image = PHP2SHELL_IMAGE.exec(ref);
6639
+ const tag = image?.[1];
6640
+ if (!image || tag === void 0 || tag === "latest") continue;
6641
+ const parsed = PHP2SHELL_TAG.exec(tag);
6642
+ const majorText = parsed?.[1];
6643
+ if (!parsed || majorText === void 0) continue;
6644
+ const major = php2shellDigits(majorText);
6645
+ const minor = parsed[2] !== void 0 ? php2shellDigits(parsed[2]) : null;
6646
+ const patch = parsed[3] !== void 0 ? php2shellDigits(parsed[3]) : null;
6647
+ if (!php2shellAffected(major, minor, patch)) continue;
6648
+ if (php2shellWebSapi(parsed[4])) {
6649
+ if (cfg013Line === null) cfg013Line = lineNo;
6650
+ } else {
6651
+ lastAffectedNonWeb = true;
6652
+ }
6653
+ }
6654
+ return {
6655
+ cfg013Line,
6656
+ cfg014Line: !capped && cfg013Line === null && lastAffectedNonWeb ? lastLine : null
6657
+ };
6658
+ }
6484
6659
  function scanConfigs(files) {
6485
6660
  const findings = [];
6486
6661
  for (const { path: filePath, content } of files) {