Skip to content

Commit d5ced1f

Browse files
docs(security): add Ollama vulnerabilities and air-gapped protocol
- Add known Ollama vulnerabilities (CNVD-2025-04094, OOB write, model poisoning) - Add 3-stage air-gapped model verification protocol - Correct RAM requirements: 32GB min for 24B, 48GB for 32B+64K - Document KV Cache Quantization (q4_0, reduces cache 75%) - Add warning for non-agentic models (Llama3.1:8b = 15% SWE-bench) - Bump version to 1.4.1 Sources: Cisco Shodan Case Study, Perplexity research report Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 43973a8 commit d5ced1f

5 files changed

Lines changed: 141 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
**Security**
12+
**Security Documentation (Ollama)**
13+
- 🔐 Added Ollama security vulnerabilities section in `docs/SECURITY.md`:
14+
- CNVD-2025-04094: No authentication by default (Critical)
15+
- Model File OOB Write: RCE potential via malformed .gguf (High)
16+
- Model Poisoning: Unrestricted upload API (High)
17+
- 🔐 Added recommended hardening steps (firewall, resource limits)
18+
- 🔐 Source: Cisco Shodan Case Study on Ollama (2025)
19+
20+
**Air-Gapped Model Verification Protocol**
21+
- 🔒 Added 3-stage verification protocol in `docs/SECURITY.md`:
22+
- Stage 1: Download with SHA-256 checksums
23+
- Stage 2: Transfer with archive verification
24+
- Stage 3: Import with individual checksum verification
25+
- 🔒 Added audit trail requirements for regulated environments
26+
- 🔒 Reference: GitHub Issue #9756 (Ollama cannot verify integrity in air-gapped)
27+
28+
**KV Cache Quantization Documentation**
29+
- ✨ Documented `OLLAMA_KV_CACHE_TYPE=q4_0` (Ollama 2025 feature)
30+
- ✨ Reduces KV cache memory by ~75% (48GB → 12GB for 64K context)
31+
- ✨ Enables 64K context on 32GB machines
32+
33+
### Changed
34+
35+
**Memory Requirements Updated**
36+
- 🔧 Corrected RAM specs in `CLAUDE.md`:
37+
- Devstral 24B: 30-37GB total (was 23-27GB)
38+
- Granite4 32B: 34-41GB total
39+
- **Minimum**: 32GB for 24B, **48GB recommended** for 32B + 64K
40+
- 🔧 Updated `docs/OPTIMISATION-M4-PRO.md` with q4_0 cache type
41+
42+
**Model Recommendations**
43+
- ⚠️ Added warning for non-agentic models in `CLAUDE.md`:
44+
- CodeLlama:13b (~40% SWE-bench) - No tool calling
45+
- Llama3.1:8b (**15%** SWE-bench) - "Catastrophic failure" on agentic tasks
46+
- ⚠️ Note: High HumanEval ≠ agentic capability (Llama3.1:8b = 68% HumanEval but 15% SWE-bench)
47+
48+
### Security
49+
1350
- 🔐 Added `.gitleaks.toml` configuration for secret detection
1451
- 🔐 Added GitHub Actions workflow `.github/workflows/security-scan.yml` for automated security scanning
1552
- 🔐 Gitleaks scans on every push/PR to detect accidentally committed credentials

CLAUDE.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,13 @@ ollama create devstral-64k -f ~/.ollama/Modelfile.devstral-64k
156156
**Verify effective context:** `ollama ps` (not `ollama show`)
157157

158158
**Memory footprint on M4 Pro 48GB with 64K context:**
159-
- Devstral Q4_K_M: 15GB model + 8-12GB cache = **23-27GB total**~21GB libre
160-
- Recommendation: 32K for comfort, 64K possible but tight
159+
- Devstral Q4_K_M (24B): 18-22GB model + 12-15GB KV cache = **30-37GB total**
160+
- Granite4 (32B): 22-26GB model + 12-15GB KV cache = **34-41GB total**
161+
- **Minimum RAM**: 32GB for 24B models, **48GB recommended** for 32B + 64K context
162+
163+
**KV Cache Quantization (Ollama 2025 feature):**
164+
- Enable with `OLLAMA_KV_CACHE_TYPE=q4_0` to reduce cache memory by ~75%
165+
- Enables 64K context on 32GB machines (previously required 48GB+)
161166

162167
**Recommendations by Project Size:**
163168
| Project Size | Files | Recommended Solution |
@@ -177,6 +182,14 @@ ollama create devstral-64k -f ~/.ollama/Modelfile.devstral-64k
177182
| ibm/granite4:small-h | 32B (9B active) | ~62% | 1M | Long context, 70% less VRAM |
178183
| qwen3-coder:30b | 30B | 85% | 256K | Highest accuracy, needs template work |
179184

185+
**⚠️ Models NOT recommended for agentic tasks:**
186+
| Model | SWE-bench | Why Not |
187+
|-------|-----------|---------|
188+
| CodeLlama:13b | ~40% | No tool calling, weak on multi-file editing |
189+
| Llama3.1:8b | **15%** | "Catastrophic failure" on agentic tasks - cannot reliably use tools |
190+
191+
> **Note**: High HumanEval scores (Llama3.1:8b = 68%) do NOT indicate agentic capability. SWE-bench measures real GitHub issue resolution, which requires tool use and multi-step reasoning.
192+
180193
**Sources:**
181194
- [Taletskiy blog](https://taletskiy.com/blogs/ollama-claude-code/)
182195
- [docs.ollama - Context](https://docs.ollama.com/context-length)

docs/OPTIMISATION-M4-PRO.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
```bash
1414
OLLAMA_FLASH_ATTENTION=1 # Flash Attention pour Gemma 3/Qwen 3
15-
OLLAMA_KV_CACHE_TYPE=q8_0 # KV Cache optimisé pour M4 Pro
15+
OLLAMA_KV_CACHE_TYPE=q4_0 # KV Cache quantization - reduces memory by ~75%
1616
OLLAMA_NUM_PARALLEL=4 # 4 requêtes parallèles
1717
OLLAMA_MAX_LOADED_MODELS=3 # 3 modèles chargés simultanément
1818
OLLAMA_CONTEXT_LENGTH=8192 # Contexte optimal pour 32B
1919
OLLAMA_KEEP_ALIVE=24h # Garde le modèle en RAM 24h
2020
```
2121

22+
> **New in 2025**: `OLLAMA_KV_CACHE_TYPE=q4_0` enables KV cache quantization, reducing cache memory from ~48GB to ~12GB for 64K context. This makes 64K context feasible on 32GB machines.
23+
2224
### Performances Attendues
2325

2426
| Métrique | Valeur |

docs/SECURITY.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,88 @@ cco # Should still work
185185
❯ Write a function # Works offline
186186
```
187187

188+
#### ⚠️ Ollama Security Vulnerabilities (January 2026)
189+
190+
**CRITICAL: Ollama has known security vulnerabilities that require operational mitigation.**
191+
192+
| Vulnerability | Severity | Description | Mitigation |
193+
|---------------|----------|-------------|------------|
194+
| **CNVD-2025-04094** | 🔴 Critical | No authentication by default - any network access to port 11434 can call API | Never expose port 11434; firewall to 127.0.0.1 only |
195+
| **Model File OOB Write** | 🔴 High | Malformed .gguf files can trigger out-of-bounds write (RCE potential) | Only load models from trusted sources; verify checksums |
196+
| **Model Poisoning** | 🟡 High | Unrestricted model upload API allows backdoored models | Disable upload API; whitelist approved models |
197+
198+
**Recommended Hardening**:
199+
```bash
200+
# 1. Firewall: Block external access to Ollama
201+
sudo ufw deny 11434
202+
# Or allow only localhost
203+
sudo ufw allow from 127.0.0.1 to any port 11434
204+
205+
# 2. Resource limits (prevent DoS)
206+
export OLLAMA_MAX_QUEUE=5
207+
export OLLAMA_NUM_PARALLEL=1
208+
export OLLAMA_MAX_LOADED_MODELS=1
209+
210+
# 3. Run as non-root user (if containerized)
211+
# See Dockerfile example in docs
212+
```
213+
214+
**Source**: [Cisco Shodan Case Study on Ollama (2025)](https://blogs.cisco.com/security/detecting-exposed-llm-servers-shodan-case-study-on-ollama)
215+
216+
---
217+
218+
#### 🔒 Air-Gapped Model Verification Protocol
219+
220+
**Problem**: Ollama cannot verify model integrity in air-gapped environments (GitHub Issue #9756). When models are transferred offline, the system assumes manifest data is authoritative.
221+
222+
**3-Stage Verification Protocol**:
223+
224+
**Stage 1: Download (Internet-connected system)**
225+
```bash
226+
# 1. Pull model from ollama.com
227+
ollama pull devstral-small-2
228+
229+
# 2. Compute SHA-256 for each model file
230+
sha256sum ~/.ollama/models/blobs/* > model-checksums.sha256
231+
232+
# 3. Document in audit log
233+
echo "$(date) | devstral-small-2 | $(cat model-checksums.sha256)" >> model-audit.log
234+
```
235+
236+
**Stage 2: Transfer (Physical media)**
237+
```bash
238+
# 1. Create archive
239+
tar -czf ollama-models.tar.gz ~/.ollama/models/
240+
241+
# 2. Compute archive checksum
242+
sha256sum ollama-models.tar.gz > archive.sha256
243+
244+
# 3. Transfer via USB (scan for malware before transfer)
245+
# 4. Keep checksums on separate medium for verification
246+
```
247+
248+
**Stage 3: Import (Air-gapped system)**
249+
```bash
250+
# 1. Verify archive checksum
251+
sha256sum -c archive.sha256
252+
253+
# 2. Extract models
254+
tar -xzf ollama-models.tar.gz -C ~/
255+
256+
# 3. Verify individual model checksums
257+
sha256sum -c model-checksums.sha256
258+
259+
# 4. Create Modelfile and register
260+
ollama create devstral-airgap -f ~/.ollama/Modelfile.devstral
261+
```
262+
263+
**Audit Trail Requirements** (for regulated environments):
264+
- Model name, version, parameter count
265+
- Source URL (ollama.com vs HuggingFace vs private)
266+
- SHA-256 hash at each transfer stage
267+
- Date, time, operator identity
268+
- Approval chain before loading
269+
188270
---
189271

190272
### 1.3 MCP Server Data Sharing
@@ -1424,6 +1506,6 @@ sudo ifconfig en0 up # Re-enable network
14241506

14251507
---
14261508

1427-
**Document Version**: 1.0.0
1428-
**Last Updated**: 2026-01-22
1509+
**Document Version**: 1.1.0
1510+
**Last Updated**: 2026-01-23
14291511
**Maintained By**: cc-copilot-bridge project

scripts/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.0
1+
1.4.1

0 commit comments

Comments
 (0)