nexus-agents 8.47.11 → 8.48.0

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-67LMMHAI.js";
3
+ } from "./chunk-LO36HW55.js";
4
4
  import {
5
5
  emitClawGuardViolation
6
6
  } from "./chunk-JOVBHYWW.js";
@@ -756,9 +756,13 @@ function sanitizeString(value) {
756
756
  const MAX_PASSES = 5;
757
757
  let cleaned = value;
758
758
  let commentsRemoved = 0;
759
+ let tagsRemoved = 0;
759
760
  for (let pass = 0; pass < MAX_PASSES; pass++) {
760
761
  XML_INJECTION_PATTERN.lastIndex = 0;
761
- const afterTags = cleaned.replace(XML_INJECTION_PATTERN, "");
762
+ const afterTags = cleaned.replace(XML_INJECTION_PATTERN, () => {
763
+ tagsRemoved += 1;
764
+ return "";
765
+ });
762
766
  const { cleaned: afterComments, removed } = stripHtmlComments(afterTags);
763
767
  commentsRemoved += removed;
764
768
  if (afterComments === cleaned) break;
@@ -770,7 +774,8 @@ function sanitizeString(value) {
770
774
  cleaned,
771
775
  modified: cleaned !== value,
772
776
  incomplete: probe !== cleaned,
773
- commentsRemoved
777
+ commentsRemoved,
778
+ tagsRemoved
774
779
  };
775
780
  }
776
781
  function detectPatterns(value) {
@@ -787,10 +792,11 @@ function sanitizeValue(value, stats) {
787
792
  if (patterns.length > 0) {
788
793
  stats.patterns.push(...patterns);
789
794
  }
790
- const { cleaned, modified, incomplete, commentsRemoved } = sanitizeString(value);
795
+ const { cleaned, modified, incomplete, commentsRemoved, tagsRemoved } = sanitizeString(value);
791
796
  if (modified) stats.count++;
792
797
  if (incomplete) stats.incomplete = true;
793
798
  stats.commentsRemoved += commentsRemoved;
799
+ stats.tagsRemoved += tagsRemoved;
794
800
  return cleaned;
795
801
  }
796
802
  if (Array.isArray(value)) {
@@ -813,12 +819,19 @@ function sanitizeToolInput(args) {
813
819
  sanitized: args,
814
820
  wasModified: false,
815
821
  modifiedCount: 0,
822
+ tagsRemoved: 0,
816
823
  detectedPatterns: [],
817
824
  sanitizationIncomplete: false,
818
825
  commentsRemoved: 0
819
826
  };
820
827
  }
821
- const stats = { count: 0, patterns: [], commentsRemoved: 0, incomplete: false };
828
+ const stats = {
829
+ count: 0,
830
+ patterns: [],
831
+ commentsRemoved: 0,
832
+ tagsRemoved: 0,
833
+ incomplete: false
834
+ };
822
835
  const sanitized = sanitizeValue(args, stats);
823
836
  const uniquePatterns = [...new Set(stats.patterns)];
824
837
  return {
@@ -827,7 +840,8 @@ function sanitizeToolInput(args) {
827
840
  modifiedCount: stats.count,
828
841
  detectedPatterns: uniquePatterns,
829
842
  sanitizationIncomplete: stats.incomplete,
830
- commentsRemoved: stats.commentsRemoved
843
+ commentsRemoved: stats.commentsRemoved,
844
+ tagsRemoved: stats.tagsRemoved
831
845
  };
832
846
  }
833
847
  function logSanitizationResult(result, logger, toolName) {
@@ -843,6 +857,12 @@ function logSanitizationResult(result, logger, toolName) {
843
857
  commentsRemoved: result.commentsRemoved
844
858
  });
845
859
  }
860
+ if (result.tagsRemoved > 0) {
861
+ logger.warn("Tool input sanitized \u2014 conversation-structure tags stripped", {
862
+ tool: toolName,
863
+ tagsRemoved: result.tagsRemoved
864
+ });
865
+ }
846
866
  if (result.detectedPatterns.length > 0) {
847
867
  logger.warn("Injection patterns detected in tool input", {
848
868
  tool: toolName,
@@ -1080,15 +1100,34 @@ function emitToolAudit({
1080
1100
  ...nearMiss ? { policyDecision: "would_deny" } : {}
1081
1101
  });
1082
1102
  }
1103
+ function hashRawFields(fields, args) {
1104
+ if (fields === void 0) return {};
1105
+ if (typeof args !== "object" || args === null) return {};
1106
+ const source = args;
1107
+ const out = {};
1108
+ for (const [field, hash] of Object.entries(fields)) {
1109
+ const value = source[field];
1110
+ if (typeof value === "string") out[field] = hash(value);
1111
+ }
1112
+ return out;
1113
+ }
1114
+ function unsanitizedContext(config, args) {
1115
+ return {
1116
+ wasModified: false,
1117
+ commentsRemoved: 0,
1118
+ fieldsModified: 0,
1119
+ tagsRemoved: 0,
1120
+ rawFieldHashes: hashRawFields(config.rawHashFields, args)
1121
+ };
1122
+ }
1083
1123
  function runPreChecks(config, args, mode, requestContext, logger) {
1084
- const noSanitization = { wasModified: false, commentsRemoved: 0 };
1085
1124
  const sizeResult = checkInputSize(args, logger, requestContext.requestId);
1086
1125
  if (sizeResult) {
1087
1126
  return {
1088
1127
  error: sizeResult,
1089
1128
  sanitizedArgs: args,
1090
1129
  nearMiss: false,
1091
- sanitization: noSanitization
1130
+ sanitization: unsanitizedContext(config, args)
1092
1131
  };
1093
1132
  }
1094
1133
  const sanitizeResult = sanitizeToolInput(args);
@@ -1096,7 +1135,11 @@ function runPreChecks(config, args, mode, requestContext, logger) {
1096
1135
  const sanitizedArgs = sanitizeResult.wasModified ? sanitizeResult.sanitized : args;
1097
1136
  const sanitization = {
1098
1137
  wasModified: sanitizeResult.wasModified,
1099
- commentsRemoved: sanitizeResult.commentsRemoved
1138
+ commentsRemoved: sanitizeResult.commentsRemoved,
1139
+ fieldsModified: sanitizeResult.modifiedCount,
1140
+ tagsRemoved: sanitizeResult.tagsRemoved,
1141
+ // #5385: hashed from `args`, the RAW input, before sanitization touched it.
1142
+ rawFieldHashes: hashRawFields(config.rawHashFields, args)
1100
1143
  };
1101
1144
  const refusal = checkSecurityTier(config.securityTier ?? "standard", sanitizeResult, logger);
1102
1145
  if (refusal !== null) {
@@ -2317,4 +2360,4 @@ export {
2317
2360
  VOTING_THRESHOLDS,
2318
2361
  ConsensusMetricsSchema
2319
2362
  };
2320
- //# sourceMappingURL=chunk-TBF46HBC.js.map
2363
+ //# sourceMappingURL=chunk-2SINF73A.js.map