Skip to content

Refused cursors that point away from Microsoft's services - #44

Merged
PianoNic merged 1 commit into
mainfrom
fix/cursor-check
Nov 3, 2026
Merged

PianoNic merged 1 commit into
mainfrom
fix/cursor-check

Conversation

@PianoNic

@PianoNic PianoNic commented Nov 3, 2026

Copy link
Copy Markdown
Owner

stream() and delta() called a saved cursor with the user's token, wherever it pointed. If an app accepted cursors from outside, a forged one could send that token to another server.

What changed

  • stream() and delta() raise ValueError before making any request if a cursor doesn't point to the expected service.
  • Graph kinds and delta(): the cursor must use the same scheme and host as the client's base.
  • chats and messages: the cursor must be HTTPS, on the region's chat service host or under .teams.microsoft.com.
  • Also refused: credentials in the URL, plus backslashes and whitespace, which URL parsers can disagree on.
  • docs/caching.md tells APIs that accept cursors from outside to also encrypt or sign them, and to check they belong to that user. This fix limits where a cursor can point, not whose it is.

Links Microsoft returns during a run are still followed as before.

Testing

  • 173 tests pass, including 29 new ones for forged cursors. Ruff and mypy are clean.
  • Against a real tenant, all 8 streams tried resumed from their real cursors: mail, mail folders, events, contacts, files, chats, chat messages and the activity feed. delta() resumed too, and forged cursors were refused with no failures.

stream() and delta() called a saved cursor with the user's token wherever it
pointed, so a forged one could send that token to another server. They now
raise ValueError before making any request.
@PianoNic PianoNic added the bug Something isn't working label Nov 3, 2026
@PianoNic
PianoNic merged commit 5e42e93 into main Nov 3, 2026
3 checks passed
@PianoNic
PianoNic deleted the fix/cursor-check branch November 6, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant