Skip to content

fix: replace dynamic SQL column interpolation with static field mapping#34

Closed
0x-SquidSol wants to merge 1 commit intonullxnothing:mainfrom
0x-SquidSol:fix/agents-update-sql-safety
Closed

fix: replace dynamic SQL column interpolation with static field mapping#34
0x-SquidSol wants to merge 1 commit intonullxnothing:mainfrom
0x-SquidSol:fix/agents-update-sql-safety

Conversation

@0x-SquidSol
Copy link
Copy Markdown

Summary

  • The agents:update handler built SQL SET clauses by interpolating filtered column names into the query string
  • While guarded by a whitelist Set and regex check, this pattern is fragile and violates secure SQL practices
  • Replaced with a static AGENT_COLUMN_MAP object whose keys are the sole source of column names
  • Eliminates the regex guard entirely — the object keys serve as both whitelist and documentation

Test plan

  • Update an agent's name, model, and system prompt — verify changes persist
  • Attempt to update with an invalid field — verify "No valid fields" error
  • Run pnpm run typecheck — passes clean
  • Run pnpm run test — 234/234 pass (10 pre-existing failures in workspace profile tests, unrelated)

The agents:update handler built SQL SET clauses by interpolating
filtered column names into the query string. While guarded by a
whitelist and regex, this pattern is fragile and violates secure SQL
practices. Replaced with a static AGENT_COLUMN_MAP object whose keys
are the sole source of column names, eliminating the regex guard and
making the allowed fields self-documenting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@nullxnothing nullxnothing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change weakens the whitelist instead of tightening it. key in AGENT_COLUMN_MAP on a plain object accepts inherited keys like oString and proto, so it is not equivalent to the previous explicit Set.has(...) check. If you want a static map, use Object.hasOwn(AGENT_COLUMN_MAP, key) or a null-prototype object; otherwise the whitelist claim here is not accurate.

@nullxnothing
Copy link
Copy Markdown
Owner

Closed as superseded by #75, which reapplies the corrected security hardening on top of current main. This avoids merging stale/conflicted branches and preserves the fixes with passing CI/CodeQL.

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