Skip to content

security: replace eval/compile with importlib for loading dvm_permissions.py#2609

Closed
mitre88 wants to merge 2 commits into
MobSF:masterfrom
mitre88:fix/replace-eval-with-importlib
Closed

security: replace eval/compile with importlib for loading dvm_permissions.py#2609
mitre88 wants to merge 2 commits into
MobSF:masterfrom
mitre88:fix/replace-eval-with-importlib

Conversation

@mitre88

@mitre88 mitre88 commented Apr 24, 2026

Copy link
Copy Markdown

Summary

Replace dangerous eval(compile(open(...).read(), ...)) pattern with safe importlib module loading.

Changes

  • scripts/update_android_permissions.py: Use importlib.util.spec_from_file_location and module_from_spec to properly import the Python file instead of eval/compile

Why

Using eval() and compile() to execute code read from a file is a significant security risk. Even though this is a development script, using importlib is the proper, safe way to dynamically load Python modules.

Open Source Contributor added 2 commits April 23, 2026 11:07
- Replace deprecated yaml.load() with yaml.safe_load() to prevent arbitrary code execution
- Add error logging to bare except Exception clause for better debugging
…ions.py

- Replace dangerous eval(compile(open(...).read(), ...)) pattern with safe importlib module loading
- Use importlib.util.spec_from_file_location and module_from_spec to properly import the Python file
- Eliminates risk of arbitrary code execution
@ajinabraham

Copy link
Copy Markdown
Member

Thanks for the PR. I will get back after testing this.

@mitre88 mitre88 closed this May 16, 2026
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