Skip to content

plugins/db.py parses the session transcript buffer from Redis with eval() #13663

Description

@ajanraj

get_upsert_segment_to_transcript_plugin in plugins/db.py reads the per-session transcript buffer from Redis and parses it with eval():

segments = r.get(key)            # plugin:{plugin_id}:session:{session_id}:transcript_segments
...
segments = eval(segments)        # executes arbitrary Python, not just parsing

eval executes whatever the key contains — so any value that is not the plain str(list-of-dicts) this function writes (a manual redis-cli fixup, another writer on the shared Redis instance, a corrupted value) runs as code inside the plugin process, which holds the OpenAI key and Redis credentials. A merely malformed value also crashes the /mentor webhook until the TTL lapses.

Fix: parse with ast.literal_eval (identical format — TranscriptSegment fields are all str/int/float/bool/None, so str() output is always a valid literal), decode the bytes redis-py returns, and treat a non-list literal as an empty buffer. Regression test included: a stored call-expression raises instead of executing.

Submitted as a bounty proposal per the contribution guide; PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions