Dart Mirrors Unsafe Reflection
Description
Detects unsafe usage of Dart reflection (dart:mirrors) where user-controlled input can be used in dynamic code execution. This can lead to code injection vulnerabilities when untrusted data is used to dynamically invoke methods or create new instances through reflection.
Detection Strategy
• Check if the code imports the 'dart:mirrors' library
• Look for reflection method calls like invoke(), apply(), or newInstance()
• Verify if user-controlled input flows into the reflection method arguments
• Report a vulnerability when all conditions are met - both reflection usage and user input in reflection arguments
Vulnerable code example
import 'dart:mirrors';
class Admin {
Admin() {
print('admin');
}
}
...✅ Secure code example
import 'dart:mirrors';
class Admin {
Admin() {
print('admin');
}
}
...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.