Skip to content

fix(connectors): keep Graph links, ids and remote file names in bounds - #3385

Merged
kunal0137 merged 7 commits into
devfrom
fix-snyk-connectors
Nov 24, 2026
Merged

kunal0137 merged 7 commits into
devfrom
fix-snyk-connectors

Conversation

@kunal0137

@kunal0137 kunal0137 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Snyk Code SSRF, path traversal and CRLF findings in the Microsoft Graph, Gmail and related connector code.

  • New prerna.io.connector.ConnectorGuards:
    • requireUnder(link, base): a link sent with the user's bearer token (for example an @odata.nextLink) must stay on the service's own scheme, host, port and base path, with no userinfo. Applied to the Graph storage engines, drive client, OneDrive, Teams, Calendar and Outlook helpers (Outlook keeps its configurable Graph base URL), and the Collaboration Graph header/message sources.
    • requirePreAuthenticated(link): pre-authenticated download/upload links must be https with a host.
    • segment(id): ids placed in URL paths are encoded only where they could change the path (ids like 19:abc@thread.v2 and b!01ABC pass through unchanged).
    • resolveWithin(root, relative): remote file names must resolve inside the real destination folder, symlinks included.
  • Gmail: CR/LF/NUL are stripped from subject, In-Reply-To/References, Content-Type and attachment file names built from received mail.
  • VirusTotal analysis id and the Graph user-search group id are encoded.
  • Every refusal is logged with the host only.

Behaviour changes

  • A link that is not under https://graph.microsoft.com (or the configured Outlook Graph base) now fails with IllegalArgumentException instead of being followed with the token.
  • A remote file name that would land outside the download folder fails that file (logged), not the batch.

Testing

  • Compile, plus a standalone check of the guards against hostile hosts, userinfo, host-prefix tricks, http, file:, dot segments, ../, absolute paths, backslashes and symlinked folders.
  • Live local run with a real Microsoft login, twice (before and after the review follow-ups): Collaboration onboarding with mail import, people photos, mail search with many results, thread reads, Teams chats, calendar and attachment downloads. No refusals and no Graph errors in the log.
  • Not exercised live: Gmail drafts, VirusTotal, the SharePoint/Teams storage engines and Outlook upload sessions.

Notes

Files in #3016 are left alone. The remaining Snyk rows in these files are false positives (host is a constant or admin config, cookies sent to a Selenium-driven browser, etc.) and will be handled as Snyk ignores.

Related Snyk PRs

Independent of each other unless noted; none are stacked.

…the service host

Add ConnectorGuards: a nextLink that is sent with the user's token must stay on graph.microsoft.com, a pre-authenticated download or upload link must be https, and ids placed in url paths are encoded only where they could change the path. Applied at the Graph request choke points (storage engine graphGet, drive client, OneDrive, Teams, Calendar, Outlook, Brain Graph sources, user search) and the VirusTotal analysis id.
Resolve names that Graph listings return against the real destination folder and refuse anything that leaves it (storage engine downloads, sync down, version download), and reduce the Teams helper's target name to a base name as the OneDrive helper already does.
Collapse CR, LF and NUL in the subject, In-Reply-To, References and carried attachment content type before they are written as headers of the outgoing draft.
@snyk-io

snyk-io Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kunal0137
kunal0137 merged commit cb0204f into dev Nov 24, 2026
3 of 4 checks passed
@kunal0137
kunal0137 deleted the fix-snyk-connectors branch November 24, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant