Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/notebooklm/cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,16 @@ async def _resolve_partial_id(
# Validate and normalize the ID
partial_id = validate_id(partial_id, entity_name)

# Skip resolution for IDs that look complete (20+ chars)
if len(partial_id) >= 20:
# Skip resolution for IDs that look complete (50+ chars)
if len(partial_id) >= 50:
return partial_id

items = await list_fn()
matches = [item for item in items if item.id.lower().startswith(partial_id.lower())]

# Do a match based on title if ther is no match on UUID:
if len(matches) == 0:
matches = [item for item in items if item.title.lower().startswith(partial_id.lower())]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

A critical Denial of Service (DoS) vulnerability exists in the title matching logic. The _resolve_partial_id function does not account for cases where an entity's title attribute is None, which is possible for Source entities. If a partial ID is provided that doesn't match any UUID, item.title.lower() will raise an AttributeError if item.title is None, causing the CLI tool to crash. An attacker could exploit this by sharing a notebook containing a source without a title. The suggested fix addresses this by safely handling None titles. Additionally, the current implementation iterates over the items list twice in the worst case, which could be optimized for better performance. There's also a minor typo in the new comment (ther -> there).

Suggested change
matches = [item for item in items if item.title.lower().startswith(partial_id.lower())]
matches = [item for item in items if (item.title or "").lower().startswith(partial_id.lower())]


if len(matches) == 1:
if matches[0].id != partial_id:
Expand Down
Loading