Back to skill

Security audit

Pydantic Ai Dependency Injection

Security checks for vulnerabilities and agentic risk

Overview

This is a documentation-only skill for PydanticAI dependency injection; its example network and credential use is disclosed and purpose-aligned, though users should handle secrets carefully.

Before installing, treat the code as a pattern reference. If adapting the examples, pass already configured clients where possible, keep API keys out of source code, and ensure any injected database or HTTP client is trusted and scoped to the task.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Missing User Warnings

Medium
Confidence
88% confidence
Finding
This markdown file includes sample code that performs an outbound HTTP request and sends a credential in the Authorization header. The surrounding skill description does not explicitly warn that dependency injection may involve network calls and secret-bearing clients, which is required for markdown content when behavior can affect privacy or system integrity.

External Transmission

Medium
Category
Data Exfiltration
Content
) -> dict:
    """Fetch weather data for a city."""
    response = await ctx.deps.client.get(
        f'https://api.weather.com/{city}',
        headers={'Authorization': ctx.deps.api_key}
    )
    return response.json()
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Intent-Code Divergence

Low
Confidence
95% confidence
Finding
The documentation explicitly states 'Pass connections, not credentials' at L190, implying dependencies should contain initialized clients rather than secrets. However, the example dependency object includes `api_key='secret'` and the tool sends it as an authorization header, which contradicts that stated guidance rather than merely omitting detail.

Static analysis

No suspicious patterns detected.