Skip to content

fix(security): remove the no-op input sanitization step - #191

Open
rahul05ranjan wants to merge 1 commit into
mainfrom
fix/remove-noop-sanitize-step
Open

rahul05ranjan wants to merge 1 commit into
mainfrom
fix/remove-noop-sanitize-step

Conversation

@rahul05ranjan

Copy link
Copy Markdown
Owner

Fixes #190

Root cause

The final step of validateInput computed this.sanitizeInput(input) and only used it for a comparison that triggered a misleading Input was sanitized warning. The sanitized value was never returned or applied: every validated request continued with the original input, so the advertised sanitization did not exist. On top of being dead code, the warning also persisted the raw original input (addressed independently for the other log calls in #189).

Fix

Delete the dead block. The real validation pipeline — the command allowlist, per-command Joi schemas, and blocked-pattern rules — is unchanged and remains the decision point for whether input may reach the model. Deliberately not wiring the escaped value in: validator.escape does HTML entity escaping, which would corrupt legitimate code text in prompts for commands like explain. sanitizeInput stays on the class for API compatibility.

Net diff: 6 lines removed, 0 added.

Verification

  • The removed block had no other effects: the comparison's only outputs were the (false) log line and nothing else, so behavior for valid input is identical.
  • No test referenced the block (grep across __tests__/ finds none); the repo's jest suite was not run here because dependencies are not installed in this environment — CI will cover it.
  • Conflicts with fix(security): redact refused input before writing security logs #189 are limited to the same method but different statements (log-call arguments vs. this removed block); either order merges with a trivial context resolution.

The sanitizeInput result was computed and then discarded: the request
always continued with the original input, while the log line claimed
'Input was sanitized'. Drop the dead step and its misleading warning.
The allowlist, per-command Joi schemas and blocked-pattern rules remain
the real validation pipeline; wiring validator.escape in instead would
corrupt legitimate code text (HTML entity escaping) before the prompt is
built. sanitizeInput stays on the class for API compatibility.

Fixes #190

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input "sanitization" in validateInput is a no-op: the sanitized value is computed and then discarded

1 participant