Please do not open a public issue for a security problem.
Report it privately through GitHub Security Advisories, or by email to abdurrafay432007@gmail.com with [ai-cache security] in the subject.
Please include what the issue is, how to reproduce it, and what an attacker could do with it. You can expect an acknowledgement within a few days and an assessment within two weeks. This is a volunteer-maintained project, so please be patient; credit is given in the advisory unless you prefer otherwise.
| Version | Supported |
|---|---|
| 0.2.x | Yes |
| 0.1.x | No - upgrade to 0.2.x |
Read this before pointing a cache at a shared or backed-up location.
ai-cache stores complete LLM requests and responses. In practice that means:
- Everything you send to the model. System prompts, user messages, retrieved documents, tool definitions and their outputs. If your prompts contain personal data, credentials, or proprietary content, that data is now in the cache file.
- Everything the model sends back.
- A short plaintext prompt excerpt per entry, used by
ai-cache lsandai-cache show. Disable it withcollect_prompt_excerpts=False.
The store is not encrypted. It is an ordinary SQLite file at ~/.ai-cache/cache.db by default, readable by anything running as your user.
API keys are never stored. Credentials, authorization headers, and client objects are excluded from cache keys and are not part of a stored entry.
- On a shared machine, keep the default per-user location and default permissions rather than moving the cache somewhere world-readable.
- Do not commit a cache file containing production or personal data. If you commit a cassette for tests, review what is in it first -
ai-cache exportmakes that straightforward. - Use
namespaceto keep tenants separate, andttlso sensitive entries do not persist indefinitely. - Set
collect_prompt_excerpts=Falsewhen prompts are sensitive and others can read the store. - For a shared Redis backend, treat the Redis instance as holding the same sensitivity as your prompts: enable authentication and TLS, and do not point it at a multi-tenant instance without a dedicated namespace.
ai-cache clearremoves entries;ai-cache prunefollows deletion with aVACUUMso the space is actually reclaimed rather than left as free pages in the file.
What the library does defensively:
- Runs with zero runtime dependencies, so it adds no third-party supply-chain surface to your environment.
- Never executes or
evals cached content. Entries are JSON; reconstruction calls the originating class's own validating constructor, and falls back to a plain dict-like object when that class is unavailable. - Parameterizes every SQL statement.
- Bounds recursion when canonicalizing requests and serializing responses, so a deeply nested structure cannot exhaust the stack.
- Degrades to a cache miss on any storage failure, rather than raising into your application.
What it does not do:
- No encryption at rest. If you need it, use an encrypted filesystem or volume.
- No integrity verification of cache contents. Anyone who can write to the cache file can control what your application receives on a hit. Treat write access to the store as equivalent to the ability to inject model output - do not share a writable cache across trust boundaries.
- No access control. The cache relies entirely on filesystem or Redis permissions.
- Semantic matching can serve a different prompt's answer. That is the feature working as designed, but if you enable it, the similarity threshold becomes a correctness control. It is off by default.
In scope: anything that lets an attacker read data they should not, cause your application to receive a response that does not correspond to its request, or execute code through cached content.
Out of scope: the cache being unencrypted at rest (documented above), and vulnerabilities in provider SDKs or Redis themselves - please report those upstream.