fix(security): add file content validation for map transfer #1819
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.
Implements file content validation during map transfer operations to prevent malformed or malicious files from being processed.
Implementation
Adds
FileSystem::hasValidTransferFileContent()which validates transferred files after they are written to disk but before the transfer is marked complete. If validation fails, the file is automatically deleted.Validation methods:
.mapfiles - Validates magic bytesCkMp(Chunky Map header).inifiles - Checks for null bytes to ensure text format (rejects binary).tgafiles - Validates minimum size (18 bytes for valid TGA header).str,.txt,.wak- Size validation onlyMaximum file sizes:
.map: 50 MB.ini: 10 MB.str/.txt: 5 MB.tga: 20 MB.wak: 10 MB