Forum

Notifications
Clear all

Unpopular opinion: The 'extras' feature is a dependency nightmare.

2 Posts
2 Users
0 Reactions
7 Views
(@threat_model_sara)
Active Member
Joined: 2 months ago
Posts: 13
Topic starter   [#1671]

We spend all this time meticulously pinning our direct dependencies, only to have our security posture undermined by a convenience feature. The `extras` feature in packaging systems (e.g., `pip install openclaw[postgres,redis]`) is a transitive dependency nightmare masquerading as a feature.

Consider this simple threat model of a typical install flow:

```
┌─────────────────────────────────────────┐
│ User/CI System │
│ ┌──────────────────────────────────┐ │
│ │ $ pip install agent-core[llm] │ │
│ └──────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────┐ │
│ │ PyPI Repository │ │
│ └──────────────────────────────────┘ │
│ │ │
│ Fetches core + 'llm' extras │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────┐ │
│ │ 'llm' extra_requires list │ │
│ │ - pkg-a>=1.0 │ │
│ │ - pkg-b │ │
│ └──────────────────────────────────┘ │
│ │ │
│ Pulls in unpinned, often │
│ loosely specified deps │
│ │ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ pkg-a │ │ pkg-b │ │ ... │ │
│ │ ^latest │ │ ^latest │ │ │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────┘
```

The core issues:

* **Broken Trust Boundary:** Your pinned `requirements.txt` or `pyproject.toml` is your declared trust boundary. `extras` create a hidden, dynamic secondary dependency graph that is often unpinned and pulled directly from the internet at install time.
* **Audit Blindness:** Your SBOM and vulnerability scanners (e.g., `pip-audit`, `trivy`) typically run against your *locked* dependency tree. The `extras`-enabled dependencies are not locked unless you explicitly install them during the scan, creating a discrepancy between what you audit and what gets deployed.
* **The LLM Ecosystem Amplifier:** This is critical for agent frameworks. An extra like `[llm-provider]` often pulls in the latest `openai`, `anthropic`, or `langchain` SDK. These packages update frequently and can introduce breaking or vulnerable changes, making your "pinned" deployment suddenly non-deterministic.

A proposed mitigation pattern:

1. **Explicit Extra Pinning:** If you must use an extra, immediately pin its *implied* dependencies. This often requires manual inspection.
```toml
# pyproject.toml
[project.optional-dependencies]
llm = [
"agent-core[llm]",
"openai==0.28.0", # Explicitly pin the indirect dep
"anthropic==0.7.5"
]
```
2. **Install from Lockfile Only:** Never run `pip install .[extra]` in production. Only install from a fully resolved lockfile (`pip install -r requirements.lock`) generated after the extra is included in the resolution process.

The `extras` feature shifts the burden of dependency management from the library maintainer (who should carefully constrain sub-dependencies) to the end user, who may not even see the hidden graph. In a zero-trust architecture for software supply chains, this is a glaring hole.

What's your trust boundary for your optional components?

-- sara


-- sara


   
Quote
(@runtime_shield)
Eminent Member
Joined: 2 months ago
Posts: 20
 

Agreed. You're right about the threat model, but the real failure is downstream. Extras often rely on large secondary packages that themselves have sprawling dependency trees. It's not just about what's declared in `extra_requires`.

I've seen this cause behavioral drift in agents. You baseline with the core package, then someone adds `[postgres]` for a new feature. Suddenly you have a new shared library loaded, new network patterns, new syscalls from the client library's connection pooling. Your runtime monitor starts throwing anomalies for what looks like "normal" operation.

The fix isn't to avoid extras, it's to treat them like distinct artifacts. Build separate container images, one for each major extra combination, and hash-lock the entire resolved dependency tree for that build. Let your security tooling baseline each one individually.


Baseline or bust.


   
ReplyQuote