Skip to content

Add input sanitization library for all user-facing string parameters preventing injection and encoding attacks #161

Description

@ALLEN-AYODEJI

Description

User-supplied arguments (agreement_id, proof_uri, addresses) are passed with minimal validation. While the shell-out injection fix addresses command injection, argument encoding issues remain: null bytes, control characters, Unicode normalization attacks, and non-printable characters could cause subtle bugs or bypass validation.

Requirements and context

  • Security: Standard security review required for state-mutating changes
  • Testing: Full test suite must pass; new tests for changed behavior
  • Documentation: Update doc comments and README if user-facing

Suggested execution

Branch: fix/feat/security-input-sanitization

Implement changes

  • Create an InputSanitizer module with functions: sanitize_hex_id, sanitize_proof_uri, sanitize_address
  • Reject null bytes, control characters (0x00-0x1F), and Unicode non-characters
  • Normalize Unicode to NFC to prevent homoglyph attacks in proof_uri
  • Apply sanitization in every CLI command before passing arguments to rpc.rs

Test and commit

Test with null byte injection, control characters, Unicode homoglyphs, and very long strings. Verify all are rejected or sanitized. Run cargo test.

Example commit message

feat(security): add comprehensive input sanitization for all CLI string parameters

Guidelines

  • Open a PR against master
  • Keep PR focused on this single concern
  • Run cargo test or npm test before review
  • Ensure no lint or typecheck warnings

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions