Skip to content

Secure repository file paths and stream downloads - #1024

Merged
aaronzi merged 2 commits into
eclipse-basyx:mainfrom
aaronzi:main
Jul 3, 2026
Merged

Secure repository file paths and stream downloads#1024
aaronzi merged 2 commits into
eclipse-basyx:mainfrom
aaronzi:main

Conversation

@aaronzi

@aaronzi aaronzi commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes unsafe repository file handling for thumbnails, submodel attachments, and AASX packages.

Uploaded filenames are no longer used as repository ids or filesystem paths. They are treated as logical display names only, validated centrally, and stored as metadata while repository storage uses generated ids.

Changes

  • Added shared file lifecycle helpers in FileRepositoryHelper

    • validates uploaded logical filenames
    • rejects traversal/path-like names
    • stores files under generated ids
    • preserves original filenames as metadata
    • centralizes save/update/delete behavior
    • provides safe stream and temp-file retrieval paths
  • Updated AAS thumbnail handling

    • stream downloads via repository InputStream
    • safe temp-file fallback for legacy File API
    • delete old thumbnail content after successful replacement
    • handle missing/cleared thumbnails as FileDoesNotExistException
  • Updated submodel attachment handling

    • stream HTTP downloads by idShortPath
    • avoid materializing previous files just to compare values
    • authorize streamed downloads by submodel element path, not repository id
  • Updated AASX package handling

    • use the same shared helper as thumbnails and attachments
    • reject traversal filenames on create/update
    • update package metadata before deleting old repository content
  • Preserved Java API compatibility

    • new stream methods are default methods on public interfaces
    • server implementations override them with direct streaming behavior

Tests

  • Added regression tests for malicious filenames and safe repository ids
  • Added thumbnail and submodel streaming/path traversal coverage
  • Added authorization coverage for attachment stream access
  • Added AASX create/update filename validation coverage

aaronzi added 2 commits July 3, 2026 10:19
Centralize repository file handling through FileRepositoryHelper for AAS
thumbnails, submodel attachments, and AASX packages. Uploaded logical
filenames are now validated as display names only, while stored repository
ids are generated server-side.

Stream thumbnail and attachment HTTP responses from the repository instead
of materializing repository ids as local filesystem paths. Keep legacy File
APIs compatible via safe temp-file/default fallbacks.

Update replacement/delete flows to update domain references safely and clean
up old repository entries after successful updates. Add regression coverage
for path traversal names, absolute repository keys, stream handling, and
authorization behavior.
@aaronzi
aaronzi merged commit fa9be4b into eclipse-basyx:main Jul 3, 2026
64 of 65 checks passed
@FriedJannik

FriedJannik commented Jul 3, 2026

Copy link
Copy Markdown
Member

i approve

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.

2 participants