Remove File hash tracking in shared link so that it does not break on… #1547
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Encryption and AuthTicket Refactoring: LookupHash Implementation and ActualFileHash Removal
TL;DR
File updates break the link which is used for sharing them because we are hashing actual file as part of it, this update removes it and fixes tests and improves encryption
The Issue
The current file sharing system has two critical limitations that impact security and user experience:
Weak Encryption: All files use the same fixed encryption tag
"filetype:audio"
, making the encryption vulnerable to pattern analysis and reducing security strength.Fragile AuthTickets: The
AuthTicket
struct contains anActualFileHash
field that becomes invalid when file content changes, requiring users to regenerate share links every time a file is updated, even for minor changes.Runtime Encryption Failures: The
PREChunkEncoder
was missing theLookupHash
field during instantiation, causing "invalid encryption header" errors during file downloads.These issues create a poor user experience where:
Root Cause
The root causes stem from architectural decisions in the encryption and sharing systems:
Fixed Encryption Tag: The encryption scheme was initialized with a hardcoded literal
"filetype:audio"
instead of using a deterministic, file-specific identifier.Unnecessary AuthTicket Field: The
ActualFileHash
field was included inAuthTicket
structs but was never used for validation logic - only for signature generation. This field becomes stale when file content changes.Missing PREChunkEncoder Field: The
PREChunkEncoder
struct was missing theLookupHash
field during instantiation, causing runtime encryption failures.Inconsistent Encryption Context: The system lacked a deterministic way to generate file-specific encryption keys that remain stable across file content changes.
The technical root cause analysis reveals:
Fix Proposed and Implemented
Phase 1: Remove ActualFileHash from AuthTicket Structures
Changes Made:
ActualFileHash string
field fromAuthTicket
structGetHashData()
method to excludeActualFileHash
from verificationPhase 2: Implement LookupHash-Based Encryption
Changes Made:
LookupHash string
field toPREChunkEncoder
structLookupHash: fileref.LookupHash
to PREChunkEncoder instantiation (lines 524-528)Phase 3: Update Test Suites
Test Files Updated:
Technical Implementation Details
Critical Runtime Fix: The
PREChunkEncoder
now properly initializes with the file-specificLookupHash
, resolving the "invalid encryption header" error that was occurring during file downloads.Re-encryption Enhancement: All re-encryption now uses deterministic file-specific keys that remain stable across file content changes.
Backward Compatibility: Existing encrypted files continue to work as the system gracefully handles both old and new encryption methods.
Repositories Affected
Blobber Repository
Files Modified:
Impact: Server-side re-encryption and AuthTicket validation updated with critical runtime bug fix.
Deployment Order
Deployment Order: Second (server-side changes, after Gosdk)
Testing Status
Critical Verification
Backward Compatibility
This implementation maintains full backward compatibility:
Key Achievement: Fixed critical runtime bug in PREChunkEncoder initialization that would have broken file downloads for encrypted files.
The changes provide enhanced security and improved user experience while ensuring system stability and backward compatibility.