@arcis/node 1.4.0 → 1.4.3

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/core/constants.d.ts +2 -2
  3. package/dist/core/constants.d.ts.map +1 -1
  4. package/dist/core/index.js +11 -3
  5. package/dist/core/index.js.map +1 -1
  6. package/dist/core/index.mjs +11 -3
  7. package/dist/core/index.mjs.map +1 -1
  8. package/dist/core/types.d.ts +6 -0
  9. package/dist/core/types.d.ts.map +1 -1
  10. package/dist/index.d.ts +4 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +527 -63
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +525 -65
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/logging/index.js.map +1 -1
  17. package/dist/logging/index.mjs.map +1 -1
  18. package/dist/middleware/bot-detection.d.ts.map +1 -1
  19. package/dist/middleware/cookies.d.ts.map +1 -1
  20. package/dist/middleware/csrf.d.ts +10 -0
  21. package/dist/middleware/csrf.d.ts.map +1 -1
  22. package/dist/middleware/hpp.d.ts.map +1 -1
  23. package/dist/middleware/index.d.ts +2 -0
  24. package/dist/middleware/index.d.ts.map +1 -1
  25. package/dist/middleware/index.js +671 -39
  26. package/dist/middleware/index.js.map +1 -1
  27. package/dist/middleware/index.mjs +671 -41
  28. package/dist/middleware/index.mjs.map +1 -1
  29. package/dist/middleware/main.d.ts.map +1 -1
  30. package/dist/middleware/rate-limit.d.ts.map +1 -1
  31. package/dist/middleware/signup-protection.d.ts +65 -0
  32. package/dist/middleware/signup-protection.d.ts.map +1 -0
  33. package/dist/middleware/telemetry.d.ts +36 -0
  34. package/dist/middleware/telemetry.d.ts.map +1 -0
  35. package/dist/sanitizers/encode.d.ts.map +1 -1
  36. package/dist/sanitizers/index.d.ts +1 -0
  37. package/dist/sanitizers/index.d.ts.map +1 -1
  38. package/dist/sanitizers/index.js +113 -37
  39. package/dist/sanitizers/index.js.map +1 -1
  40. package/dist/sanitizers/index.mjs +111 -38
  41. package/dist/sanitizers/index.mjs.map +1 -1
  42. package/dist/sanitizers/ldap.d.ts +42 -0
  43. package/dist/sanitizers/ldap.d.ts.map +1 -0
  44. package/dist/sanitizers/path.d.ts.map +1 -1
  45. package/dist/sanitizers/pii.d.ts.map +1 -1
  46. package/dist/sanitizers/sanitize.d.ts.map +1 -1
  47. package/dist/sanitizers/ssti.d.ts.map +1 -1
  48. package/dist/sanitizers/xxe.d.ts.map +1 -1
  49. package/dist/stores/index.js +21 -1
  50. package/dist/stores/index.js.map +1 -1
  51. package/dist/stores/index.mjs +21 -1
  52. package/dist/stores/index.mjs.map +1 -1
  53. package/dist/stores/memory.d.ts +4 -10
  54. package/dist/stores/memory.d.ts.map +1 -1
  55. package/dist/telemetry/client.d.ts +60 -0
  56. package/dist/telemetry/client.d.ts.map +1 -0
  57. package/dist/telemetry/index.d.ts +3 -0
  58. package/dist/telemetry/index.d.ts.map +1 -0
  59. package/dist/telemetry/types.d.ts +59 -0
  60. package/dist/telemetry/types.d.ts.map +1 -0
  61. package/dist/validation/index.js +41 -21
  62. package/dist/validation/index.js.map +1 -1
  63. package/dist/validation/index.mjs +41 -21
  64. package/dist/validation/index.mjs.map +1 -1
  65. package/package.json +8 -2
@@ -9,6 +9,9 @@ var XSS_REMOVE_PATTERNS = [
9
9
  /<script[^>]*>[\s\S]*?<\/script>/gi,
10
10
  /** Standalone/unclosed script tags */
11
11
  /<script[^>]*>/gi,
12
+ /** style — CSS expression() and behavior: attacks (IE-era but still relevant) */
13
+ /<style[^>]*>[\s\S]*?<\/style>/gi,
14
+ /<style[^>]*/gi,
12
15
  /** iframe — full block and partial/unclosed */
13
16
  /<iframe[^>]*>[\s\S]*?<\/iframe>/gi,
14
17
  /<iframe[^>]*/gi,
@@ -29,7 +32,15 @@ var XSS_REMOVE_PATTERNS = [
29
32
  /javascript\s*:/gi,
30
33
  /vbscript\s*:/gi,
31
34
  /** data: URIs with HTML/script content */
32
- /data\s*:\s*text\/html[^>\s]*/gi
35
+ /data\s*:\s*text\/html[^>\s]*/gi,
36
+ /** form tag injection — phishing via action= redirection */
37
+ /<form[\s>][^>]*/gi,
38
+ /** meta tag injection — http-equiv refresh or CSP bypass */
39
+ /<meta[\s>][^>]*/gi,
40
+ /** base href hijacking */
41
+ /<base[\s>][^>]*/gi,
42
+ /** link tag injection — stylesheet or preload attacks */
43
+ /<link[\s>][^>]*/gi
33
44
  ];
34
45
  var SQL_PATTERNS = [
35
46
  /** SQL keywords */
@@ -93,8 +104,8 @@ var COMMAND_PATTERNS = [
93
104
  /[;&|`]/g,
94
105
  /** Command substitution: $( ... ) — matched as a pair to reduce false positives */
95
106
  /\$\(/g,
96
- /** URL-encoded newline/carriage-return injection (%0a, %0d) */
97
- /%0[ad]/gi
107
+ /** URL-encoded control characters (%00-%0F): null, tab, vtab, formfeed, LF, CR */
108
+ /%0[0-9a-f]/gi
98
109
  ];
99
110
  var VALIDATION = {
100
111
  /**
@@ -259,26 +270,31 @@ function sanitizePath(input, collectThreats = false) {
259
270
  const threats = [];
260
271
  let value = input;
261
272
  let wasSanitized = false;
262
- for (const pattern of PATH_PATTERNS) {
263
- pattern.lastIndex = 0;
264
- if (pattern.test(value)) {
273
+ value = value.normalize("NFKC");
274
+ let prev;
275
+ do {
276
+ prev = value;
277
+ for (const pattern of PATH_PATTERNS) {
265
278
  pattern.lastIndex = 0;
266
- if (collectThreats) {
267
- const matches = value.match(pattern);
268
- if (matches) {
269
- for (const match of matches) {
270
- threats.push({
271
- type: "path_traversal",
272
- pattern: pattern.source,
273
- original: match
274
- });
279
+ if (pattern.test(value)) {
280
+ pattern.lastIndex = 0;
281
+ if (collectThreats) {
282
+ const matches = value.match(pattern);
283
+ if (matches) {
284
+ for (const match of matches) {
285
+ threats.push({
286
+ type: "path_traversal",
287
+ pattern: pattern.source,
288
+ original: match
289
+ });
290
+ }
275
291
  }
276
292
  }
293
+ value = value.replace(pattern, "");
294
+ wasSanitized = true;
277
295
  }
278
- value = value.replace(pattern, "");
279
- wasSanitized = true;
280
296
  }
281
- }
297
+ } while (value !== prev);
282
298
  if (collectThreats) {
283
299
  return { value, wasSanitized, threats };
284
300
  }
@@ -336,7 +352,7 @@ function sanitizeString(value, options = {}) {
336
352
  if (value.length > maxSize) {
337
353
  throw new InputTooLargeError(maxSize, value.length);
338
354
  }
339
- const reject = options.mode !== "sanitize";
355
+ const reject = options.mode === "reject";
340
356
  let result = value;
341
357
  if (options.sql !== false) {
342
358
  if (reject) {
@@ -791,8 +807,12 @@ function checkPrivateIp(hostname) {
791
807
  if (hostname === "metadata.google.internal" || hostname === "metadata.internal" || hostname === "metadata.azure.internal") {
792
808
  return "cloud metadata endpoint";
793
809
  }
794
- const ipv6 = hostname.replace(/^\[|\]$/g, "");
795
- if (ipv6 === "::1" || ipv6 === "::" || ipv6.startsWith("fc") || ipv6.startsWith("fd") || ipv6.startsWith("fe80")) {
810
+ let ipv6 = hostname.replace(/^\[|\]$/g, "");
811
+ const zoneIdx = ipv6.indexOf("%");
812
+ if (zoneIdx !== -1) {
813
+ ipv6 = ipv6.slice(0, zoneIdx);
814
+ }
815
+ if (ipv6 === "::1" || ipv6 === "::" || /^fc[0-9a-f]{2}:/i.test(ipv6) || /^fd[0-9a-f]{2}:/i.test(ipv6) || /^fe80:/i.test(ipv6) || /^ff[0-9a-f]{2}:/i.test(ipv6)) {
796
816
  return "private IPv6 address";
797
817
  }
798
818
  const mappedDotted = ipv6.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i);