Skip to content

feat: Deeplinks hardenning - #1988

Merged
adrien-coye merged 7 commits into
masterfrom
feat/deeplinks-hardenning
Aug 14, 2026
Merged

adrien-coye merged 7 commits into
masterfrom
feat/deeplinks-hardenning

Conversation

@adrien-coye

@adrien-coye adrien-coye commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Hardens shared-file deeplinks with a deliberately narrow scope:

kDrive only accepts regular files placed by trusted Infomaniak apps in the dedicated app-group handoff directory.

Hardening Methods

  • Requires the exact kdrive-file-sharing://file route.
  • Rejects URLs containing an unexpected path, credentials, port, or fragment.
  • Accepts only non-empty url query parameters.
  • Limits each request to 100 files.
  • Requires every supplied path to be absolute.
  • Sanitizes filenames using safeLastPathComponent.
  • Rejects malformed, repeatedly percent-encoded, oversized, or control-character filenames.
  • Restricts files to Library/Caches/file-sharing/<UUID>/<filename>.
  • Uses path components instead of string prefixes for containment checks.
  • Resolves symlinks before accepting a file.
  • Rejects symlinked handoff directories, UUID directories, and source files.
  • Rejects paths escaping the shared app-group handoff directory.
  • Accepts regular files only, rejecting directories and other filesystem objects.
  • Rejects the complete request when any supplied file is invalid.
  • Passes only the validated, resolved file URL to the existing save flow.

Scope

This hardening applies only to the inter-application file-sharing deeplink. It does not introduce a generic file importer, additional staging, network downloads, or changes to other upload flows.

Dependency

Requires ios-core 19.1.3 for the hardened safeLastPathComponent implementation.

depends on Infomaniak/ios-core#205

Tests

Coverage includes:

  • Accepting a regular file from the expected handoff directory.
  • Rejecting an incorrect scheme or host.
  • Rejecting files outside the handoff directory.
  • Rejecting symlink-based path escapes.
  • Rejecting directories.

@adrien-coye adrien-coye added this to the 6.1.0 milestone Aug 6, 2026
@adrien-coye
adrien-coye force-pushed the feat/deeplinks-hardenning branch from 8866917 to 93bacfc Compare August 10, 2026 08:58
@adrien-coye
adrien-coye marked this pull request as ready for review August 10, 2026 09:00
Copilot AI balanced review requested due to automatic review settings August 10, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Hardens inter-app file-sharing deeplinks by strictly validating routes, paths, filesystem objects, and symlinks.

Changes:

  • Adds strict file-sharing deeplink validation.
  • Adds security-focused parser tests.
  • Requires ios-core 19.1.3.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Tuist/Package.swift Updates the ios-core dependency requirement.
kDriveCore/Utils/DeeplinkParser.swift Validates shared-file deeplinks and filesystem containment.
kDriveTests/kDriveCore/DeepLinks/UTFileSharingDeeplink.swift Tests valid files and key rejection cases.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Tuist/Package.swift Resolved
@PhilippeWeidmann
PhilippeWeidmann self-requested a review August 10, 2026 09:35
@adrien-coye adrien-coye added the security Related to security issues label Aug 11, 2026

@PhilippeWeidmann PhilippeWeidmann left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One quick change.
Also i wonder if some of this code should be moved in iOS-core in the DeeplinkService and the GroupContainerService which does the actual writing.

We can share the scheme and other static strings, also protect the writing directly in GroupContainerService

Comment thread kDriveCore/Utils/DeeplinkParser.swift Resolved
@adrien-coye
adrien-coye force-pushed the feat/deeplinks-hardenning branch from f311320 to 90c2ea3 Compare August 13, 2026 08:52
Comment thread kDriveCore/Utils/DeeplinkParser.swift Resolved
@adrien-coye
adrien-coye force-pushed the feat/deeplinks-hardenning branch from 29cf57f to 351a6b2 Compare August 14, 2026 09:19
@github-actions

Copy link
Copy Markdown

This PR/issue depends on:

@adrien-coye
adrien-coye enabled auto-merge August 14, 2026 09:38
@adrien-coye
adrien-coye requested a balanced review from Copilot August 14, 2026 09:38
@sonarqubecloud

Copy link
Copy Markdown

@adrien-coye

Copy link
Copy Markdown
Contributor Author

I did check the mail to drive share on device, all works fine

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

kDriveTests/kDriveCore/DeepLinks/UTFileSharingDeeplink.swift:54

  • The tests exercise only five acceptance/rejection paths, leaving security-critical branches unverified: unexpected path/credentials/port/fragment, empty or unknown query items, the 100-file boundary, relative and malformed/repeatedly encoded paths, symlinked handoff/UUID directories, and all-or-nothing rejection for mixed requests. Add focused negative and boundary cases so future parser changes cannot silently widen this contract.
    func testRejectsWrongRoute() throws {

Comment thread kDriveCore/Utils/DeeplinkParser.swift Resolved
@adrien-coye
adrien-coye merged commit d389f8f into master Aug 14, 2026
14 of 15 checks passed
@adrien-coye
adrien-coye deleted the feat/deeplinks-hardenning branch August 14, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Related to security issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants