mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-09 15:19:11 +02:00
Merge pull request #1424 from aaronjmars/security/validate-package-id-in-request-builder
harden: validate package-name charset in request_builder
This commit is contained in:
commit
b051be8162
1 changed files with 16 additions and 0 deletions
|
|
@ -206,6 +206,22 @@ pub fn apply_pkg_state_commands(
|
|||
/// which act on a common `package` and `user`.
|
||||
#[must_use]
|
||||
pub fn request_builder(commands: &[&str], package: &str, user: Option<User>) -> Vec<String> {
|
||||
// Defense-in-depth: `package` is interpolated verbatim into a device-shell
|
||||
// action, so refuse any name carrying a character that can't appear in a valid
|
||||
// Android application-ID (`[A-Za-z0-9_.]`). Every current caller already
|
||||
// reconciles the name against the live device package list before reaching
|
||||
// here, so this rejects nothing legitimate — it just keeps the no-injection
|
||||
// guarantee local to the sink instead of relying on each caller to sanitise.
|
||||
// Fail closed: emit no command for a malformed name rather than an injectable
|
||||
// device-shell string.
|
||||
if package.is_empty()
|
||||
|| !package
|
||||
.bytes()
|
||||
.all(|b| b.is_ascii_alphanumeric() || b == b'.' || b == b'_')
|
||||
{
|
||||
error!("request_builder: refusing package name with invalid characters: {package:?}");
|
||||
return Vec::new();
|
||||
}
|
||||
let maybe_user_flag = user_flag(user);
|
||||
commands
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue