Skip to content

Conversation

@BykhovDenis
Copy link
Member

No description provided.

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
@BykhovDenis BykhovDenis self-assigned this Dec 9, 2025
@huly-github-staging
Copy link

Connected to Huly®: UBERF-14401

part = part.slice(0, -1)
}
if (curr[part] === undefined) {
curr[part] = {}

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix

AI about 1 month ago

The best way to fix this issue is to prevent malicious keys such as "__proto__", "constructor", and "prototype" from ever being used as object property names in the intermediate data structure. This can be achieved by adding a check before assignment for each property name, skipping or rejecting any that could be used for prototype pollution. A robust implementation should use a helper function to perform this check and only allow safe keys.

Specifically:

  • Edit the method buildaAssociation in plugins/view-resources/src/utils.ts to prevent property assignment if part equals "__proto__", "constructor", or "prototype" (or other dangerous keys).
  • The check should be applied on every iteration in the for ... of parts loop, where curr[part] is being accessed and assigned.
  • Optionally, you can define a small utility function or a set in the file to keep this logic clean.
  • You do not need to change the data structure to a Map—the risk is managed as long as dangerous keys cannot enter as properties.
  • Only modify the code in the region shown; do not change other logic.

Suggested changeset 1
plugins/view-resources/src/utils.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/plugins/view-resources/src/utils.ts b/plugins/view-resources/src/utils.ts
--- a/plugins/view-resources/src/utils.ts
+++ b/plugins/view-resources/src/utils.ts
@@ -518,6 +518,12 @@
   return convertAssociationsRecord(record)
 }
 
+// Prevent prototype pollution by skipping dangerous property names
+const dangerousKeys = new Set(['__proto__', 'constructor', 'prototype']);
+function isSafeKey(key: string): boolean {
+  return !dangerousKeys.has(key);
+}
+
 function buildaAssociation (stringKey: string, record: Record<string, any>): void {
   const parts = stringKey.split('$associations.').filter((it) => it.length > 0)
   let curr = record
@@ -525,10 +531,11 @@
     if (part.endsWith('.')) {
       part = part.slice(0, -1)
     }
+    if (!isSafeKey(part)) continue;
     if (curr[part] === undefined) {
       curr[part] = {}
     }
-    curr = record[part]
+    curr = curr[part]
   }
 }
 
EOF
@@ -518,6 +518,12 @@
return convertAssociationsRecord(record)
}

// Prevent prototype pollution by skipping dangerous property names
const dangerousKeys = new Set(['__proto__', 'constructor', 'prototype']);
function isSafeKey(key: string): boolean {
return !dangerousKeys.has(key);
}

function buildaAssociation (stringKey: string, record: Record<string, any>): void {
const parts = stringKey.split('$associations.').filter((it) => it.length > 0)
let curr = record
@@ -525,10 +531,11 @@
if (part.endsWith('.')) {
part = part.slice(0, -1)
}
if (!isSafeKey(part)) continue;
if (curr[part] === undefined) {
curr[part] = {}
}
curr = record[part]
curr = curr[part]
}
}

Copilot is powered by AI and may make mistakes. Always verify output.
@ArtyomSavchenko ArtyomSavchenko merged commit 83e110f into develop Dec 10, 2025
17 checks passed
@BykhovDenis BykhovDenis deleted the traceability_matrix_preparation branch December 18, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants