Security hardening: treat repository-controlled state as untrusted (.code-index/, .code-index.toml, git config, committed index.db) #380

Closed
opened 2026-10-15 15:37:34 +02:00 by buildagent · 1 comment
Member

Found by the 2026-10-15 whole-project review. Severity: high. This is pre-existing; no recent change introduced it. Reproduction details are kept off this public tracker on purpose.

Class of problem

code-index treats several inputs that a repository can ship as if the user created them:

  1. The .code-index/ state directory. It is opened and written without checking that it is a real directory owned by the current user, and state files are written without symlink protection.
  2. .code-index.toml.
    • [[links]] may point anywhere, including the home directory.
    • The file-size cap can be raised far above the default, and the builtin parse path has no deadline.
    • read_code serves files under a root even when they were never indexed.
  3. Git configuration in the working tree. The neutralizer for attribute-driven filters does not cover every way a configuration can declare one.
  4. A pre-existing index.db. It is opened with SQLite's default trust settings.

The deliberately designed boundaries were reviewed and are sound: RPC auth, package signing and the archive format, the wasm guest, path containment, and SQL parameters.

Direction

Generic rather than per case:

  • One startup check: the state directory must be a real directory owned by the user, state files are opened no-follow and create-new, and a database this build did not create is never trusted (trusted_schema=OFF).
  • Links from a repository manifest need user approval in the existing user-scoped store.
  • read_code is limited to indexed paths.
  • A size cap above the default is honoured only from user-scoped config, and parsing gets a deadline.
  • Git runs with attribute sources and submodule drivers neutralised.

Also in scope:

  • The PR CI checkout keeps a token that release jobs also use.
  • install.sh should force https.
Found by the 2026-10-15 whole-project review. Severity: high. This is pre-existing; no recent change introduced it. Reproduction details are kept off this public tracker on purpose. ## Class of problem code-index treats several inputs that a repository can ship as if the user created them: 1. **The `.code-index/` state directory.** It is opened and written without checking that it is a real directory owned by the current user, and state files are written without symlink protection. 2. **`.code-index.toml`.** - `[[links]]` may point anywhere, including the home directory. - The file-size cap can be raised far above the default, and the builtin parse path has no deadline. - `read_code` serves files under a root even when they were never indexed. 3. **Git configuration in the working tree.** The neutralizer for attribute-driven filters does not cover every way a configuration can declare one. 4. **A pre-existing `index.db`.** It is opened with SQLite's default trust settings. The deliberately designed boundaries were reviewed and are sound: RPC auth, package signing and the archive format, the wasm guest, path containment, and SQL parameters. ## Direction Generic rather than per case: - One startup check: the state directory must be a real directory owned by the user, state files are opened no-follow and create-new, and a database this build did not create is never trusted (`trusted_schema=OFF`). - Links from a repository manifest need user approval in the existing user-scoped store. - `read_code` is limited to indexed paths. - A size cap above the default is honoured only from user-scoped config, and parsing gets a deadline. - Git runs with attribute sources and submodule drivers neutralised. Also in scope: - The PR CI checkout keeps a token that release jobs also use. - `install.sh` should force https.
Author
Member

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): repository-declared [[links]] and a raised max_file_size_mb are requests granted by code-index approve; built-in parsing has the per-file deadline; read_code serves only indexed files; one git command builder neutralises repository-configured programs and skips submodules; installers use https with TLS 1.2+.

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): repository-declared `[[links]]` and a raised `max_file_size_mb` are requests granted by `code-index approve`; built-in parsing has the per-file deadline; `read_code` serves only indexed files; one git command builder neutralises repository-configured programs and skips submodules; installers use https with TLS 1.2+.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#380
No description provided.