Skip to content

fix: add URL validation in run-transfer.mjs - #106

Merged
LauJoeYing merged 1 commit into
Virtual-Protocol:mainfrom
anupamme:fix-repo-acp-cli-demos-ssrf-compass-url-validation
Aug 6, 2026
Merged

fix: add URL validation in run-transfer.mjs#106
LauJoeYing merged 1 commit into
Virtual-Protocol:mainfrom
anupamme:fix-repo-acp-cli-demos-ssrf-compass-url-validation

Conversation

@anupamme

@anupamme anupamme commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix high severity security issue in showcase/compass-guarded-transfer/scripts/run-transfer.mjs.

Vulnerability

Field Value
ID V-002
Severity HIGH
Scanner multi_agent_ai
Rule V-002
File showcase/compass-guarded-transfer/scripts/run-transfer.mjs:35
Assessment Likely exploitable
CWE CWE-918

Description: The normalizeInput function validates some input fields but fails to properly validate the compassUrl parameter. While it checks that compassUrl starts with 'https://', it does not validate the URL format comprehensively or prevent SSRF (Server-Side Request Forgery) attacks. The function accepts any HTTPS URL and passes it directly to the verify() function at line 48, which makes an HTTP POST request to that URL. An attacker can provide a malicious URL pointing to internal services or cloud metadata endpoints.

Evidence

Exploitation scenario: An attacker provides a malicious compassUrl like 'https://169.254.169.254/latest/meta-data/' (AWS metadata endpoint) or 'https://localhost:8080/admin' (internal service).

Scanner confirmation: multi_agent_ai rule V-002 flagged this pattern.

Threat Model Context

This is a local CLI tool - exploitation requires the attacker to control command-line arguments or input files.

Changes

  • showcase/compass-guarded-transfer/scripts/run-transfer.mjs

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.

Security Invariant

Property: The security boundary is maintained under adversarial input

Regression test
import { normalizeInput } from '../showcase/compass-guarded-transfer/scripts/run-transfer.mjs';

describe("normalizeInput must reject SSRF-vulnerable compassUrl values", () => {
  const payloads = [
    // Exploit case: internal service URL
    { compassUrl: 'https://169.254.169.254/latest/meta-data/', recipient: '11111111111111111111111111111111', amountSol: '0.0001', amountUsdPolicyInput: '0.01', confirmed: 'yes', cluster: 'devnet', apiKey: 'test' },
    // Boundary case: malformed HTTPS URL
    { compassUrl: 'https://', recipient: '11111111111111111111111111111111', amountSol: '0.0001', amountUsdPolicyInput: '0.01', confirmed: 'yes', cluster: 'devnet', apiKey: 'test' },
    // Valid input (should pass)
    { compassUrl: 'https://compass.example.com/verify', recipient: '11111111111111111111111111111111', amountSol: '0.0001', amountUsdPolicyInput: '0.01', confirmed: 'yes', cluster: 'devnet', apiKey: 'test' }
  ];

  test.each(payloads)("rejects adversarial input: %s", (payload) => {
    if (payload.compassUrl === 'https://compass.example.com/verify') {
      // Valid case should normalize successfully
      const result = normalizeInput(payload);
      expect(result.compassUrl).toBe('https://compass.example.com/verify');
    } else {
      // Adversarial cases must throw
      expect(() => normalizeInput(payload)).toThrow();
    }
  });
});

This test guards against regressions — it's useful independent of the code change above.


Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@LauJoeYing
LauJoeYing merged commit 917e770 into Virtual-Protocol:main Aug 6, 2026
2 checks passed
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.

2 participants