Skip to content

Security: API session lock map grows without bounds #4883

Description

@hamb1y

Security / reliability issue

The API stores one asyncio.Lock forever for every caller-provided session_id:

session_lock = session_locks.setdefault(session_key, asyncio.Lock())

This is at nanobot/api/server.py:240 and the dictionary is initialized at line 413. There is no TTL, eviction, maximum size, or identity-based keying.

Impact

An attacker can send many unique session IDs and grow process memory indefinitely. This also allows unbounded lock bookkeeping even when requests finish.

Suggested fix

Use bounded/LRU lock storage, remove idle locks safely, cap session IDs, or derive locks from an authenticated principal rather than arbitrary request input. Add a regression test for bounded growth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions