Bevy exposes access to the entire file system to scripts and/or mods.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
In PR #18023 it was noticed that bevy's `AssetServer` places no restrictions on which files the executable can load, meaning any scripting system or loaded mod could potentially harvest arbitrary amounts of user data.
This Issue is concerned with how best to address the security vulnerability in which mods or scripts could harvest arbitrary user data using bevy's built in file reader systems, such as, but not limited to, the `AssetPlugin`.
## Proposed solution
In line with the discussion on #18023, I propose the `AssetServer::load` have limits placed on which files it will load. These limits are that the file must meet one of the following criteria:
- Is located inside the directory `AssetPlugin::file_path` AND asset processing is disabled
- Is located inside the directory `AssetPlugin::processed_file_path` AND asset processing is enabled
- Is located in a different `AssetSource`, either the default file path or the processed file path, depending on if asset processing is enabled.
In total, this should prevent the asset system from loading any files not in one of the folders designated as an asset source by the developers.
## Additional Work
The rest of the bevy code base should be searched for other instances of filesystem access. Where found, these plugins should either have comparable safety measures imposed, or have warnings added to the documentations of Events, Resources, States, SystemParams, etc which can result in any file read or write.
Additionally, I recommend adding warnings and safety recommendations to the bevy book around the topics of mod support, scripting systems, and asset loading.
Contributor guide
Research direction
Start with PR #18023 and the AssetServer::load and AssetPlugin behavior described here. Audit other filesystem access across Bevy, then determine which plugins need comparable restrictions and which documentation areas need warnings. Done means asset loading is limited to designated AssetSources and the relevant APIs and Bevy Book sections document mod and scripting safety recommendations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev, security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100