Closed
Conversation
- env: guard PI_CODING_AGENT_DIR against null-byte injection; normalise to an absolute path via path.resolve() - oauth: cap auth responses at 1 MB (content-length header + body length) to prevent memory exhaustion from a malicious or compromised server - oauth: change fetchJson return type from T to T | null; callers now explicitly check for null instead of receiving undefined silently cast as T, closing a potential null-dereference in all three call-sites (initiateDeviceAuth, pollDeviceAuth, fetchProfile) - oauth: reject org IDs containing control characters (CR, LF, NUL, etc.) before injecting them into HTTP headers to prevent header injection; defence-in-depth alongside modern fetch implementations - models: add isValidCacheFile() type guard; readCache() now validates the JSON structure before trusting it, so a tampered cache file cannot inject arbitrary model configuration - models: cap model-list fetch at 50 MB and assert the data array shape before returning - tests: 14 new tests covering each guard (size limits, invalid JSON, header injection, cache file tampering)
Owner
|
Thanks for the change. After reviewing the threat model, I found that these guards address scenarios that are highly unlikely to accour in this provider, so their utility does not appear to outweigh the complexity of the code. Therefore I'll close this for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several defensive fixes for scenarios where the Kilo Code API—or a
compromised network path—returns unexpected data.
Changes
src/lib/env.tsPI_CODING_AGENT_DIRagainst null-byte injection before passingit to
path.resolve()src/provider/oauth.tscontent-lengthheader andactual body length) to prevent memory exhaustion
fetchJsonreturn type fromTtoT | null; all threecall-sites (
initiateDeviceAuth,pollDeviceAuth,fetchProfile) nowexplicitly guard against a missing or unparseable body instead of
receiving
undefinedsilently cast asTbefore injecting them into HTTP headers — defence-in-depth alongside
the protections already in modern
fetchimplementationssrc/provider/models.tsisValidCacheFile()type guard;readCache()now validates theJSON structure before trusting it, so a tampered local cache file
cannot inject arbitrary model configuration
dataarray shapebefore returning
Tests
JSON, header injection via org ID, cache file tampering
package-lock.jsonnpm audit fix— resolves 4 moderate advisories (brace-expansion,fast-xml-parser,yaml,@aws-sdk/xml-builder)