-
Notifications
You must be signed in to change notification settings - Fork 28.4k
obfuscation leaks build time location of plugin registrar script #165111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@git2321231 Did you upload the Also, can you try to run your scenario on latest stable to check if it still persist ? |
@darshankawar Accessing MobSF online can be a bit slow. A simple solution is to deploy it locally using Docker. I checked this issue on Flutter 3.29.0 and it still exists.I believe this issue may affect all versions, unless there is a debate over whether Flutter should obfuscate strings. However, I am confident that this is indeed a problem, as it is properly obfuscated on Android. [!] Flutter (Channel stable, 3.29.0, on macOS 15.2 24C101 darwin-arm64, locale zh-Hans-CN) [835ms]
• Flutter version 3.29.0 on channel stable at /Users/xxx/flutter_gitee/FlutterC/Flutter
! Warning: `flutter` on your path resolves to /Users/xxx/flutter_gitee/FlutterB/flutter/bin/flutter, which is not inside your current Flutter SDK
checkout at /Users/xxx/flutter_gitee/FlutterC/Flutter. Consider adding /Users/xxx/flutter_gitee/FlutterC/Flutter/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/xxx/flutter_gitee/FlutterB/flutter/bin/dart, which is not inside your current Flutter SDK checkout
at /Users/xxx/flutter_gitee/FlutterC/Flutter. Consider adding /Users/xxx/flutter_gitee/FlutterC/Flutter/bin to the front of your path.
! Upstream repository https://gitee.com/mirrors/Flutter.git is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to https://gitee.com/mirrors/Flutter.git to dismiss this error.
• Framework revision 35c388afb5 (4 weeks ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
• Pub download mirror https://pub.dev
• Flutter download mirror https://storage.flutter-io.cn
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.5s]
• Android SDK at /Users/xxx/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Users/xxx/Library/Java/JavaVirtualMachines/jbr-17.0.8/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment JBR-17.0.8+7-1000.22-nomod (build 17.0.8+7-b1000.22)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 16.2) [2.4s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Android Studio (version 2023.3) [13ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
[✓] VS Code (version 1.98.0) [12ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.107.20250303
[✓] Connected device (5 available) [8.0s]
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
• Eric的iPhone 13 Pro Max (mobile) • 00008110-001C55202222801E • ios • iOS 18.3.1 22D72
• iPhone 16 Pro Max (mobile) • 30DCB973-D365-43B3-B794-17B6F87F56B2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
• iPad Pro 11-inch (M4) (mobile) • 999A5313-166E-4024-A82D-0743B9F4AA90 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.2 24C101 darwin-arm64
[✓] Network resources [654ms]
• All expected network resources are available.
|
Thanks for the update.
I tried this and was able to see the reported behavior.
|
Additionally, I discovered that ".dart_tool/flutter_build/dart_plugin_registrant.dart" were also being included in the IPA package, which is quite unusual. |
Strings are not obfuscated - only names and library URIs are when they are not entry points which engine needs to access by name (this is documented in https://docs.flutter.dev/deployment/obfuscate#limitations). I think that's the reason why plugin registrant entry point is retained - maybe worth having the issue about that one, but the rest is working as intended. |
Thank you for your reply. I understand that the strings at the native layer are not obfuscated. However, what I don't understand is why the strings in Dart code are well obfuscated on Android but not on iOS. I suspect that this so-called “obfuscation” ultimately relies on the native platform’s obfuscation capabilities, and it just so happens that Android obfuscates strings while iOS does not — is that correct? |
It probably means you are testing something incorrectly. There is no difference between Android and iOS when it comes to Dart obfuscation. |
No, please carefully review the reproduction steps mentioned above — you can even try them yourself. This is a very easy issue to reproduce, so please trust your colleagues on this. In the MobSF analysis reports for both the Android APK and iOS IPA, it’s easy to observe that Dart strings are not obfuscated on iOS, whereas they are properly obfuscated on Android. For example, in the iOS report, you can easily search for the string from the demo project: “You have pushed the button this many times:”. But in the Android report, this string is not searchable, indicating that it has been obfuscated. |
Then something is wrong with the tool, because as I have said - obfuscation works the same way on both Android and iOS. It is platform independent. I have implemented the thing - so I know quite well what it does and how it works. I think what happens is that MobSF is just not very good tool... Strings just go into slightly different place in the compiled binary (because Android build uses compressed pointers builds and iOS build does not) but they are present in unobfuscated form in both cases. Good old $ flutter build apk --release --split-debug-info=debug-info --obfuscate --target-platform android-arm64
...
$ strings ./build/app/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/arm64-v8a/libapp.so | grep button
button
You have pushed the button this many times: |
Alright, I understand. In that case, please also pay attention to the dart_plugin_registrant issue. Thank you. |
Can you confirm where this path is inside the IPA? |
It is a string resource in the IPA package that can be easily captured by analyze tools. Crucially, it contains the developer's username and project path information. This packaging intermediate information should not be present in the IPA package. |
@git2321231 The screenshot does not show where the |
@vashworth this file is generated by the build process in the original app source directory, e.g. if you add The problem here is how it is wired to the rest of the engine: the engine first looks up To really hide the URL the file probably needs to be placed in a synthetic package (similar to |
Steps to reproduce
1.Create a default Flutter demo project.
2.Use commands packaged into IPA:flutter build ipa --release --obfuscate --split-debug-info=build/ios/ipa
3.Analysis the IPA using some static analysis tools,such as MobSF(https://mobsf.live/).
Expected results
We should see that the static analysis tool cannot directly find the string code in the Demo project.
Actual results
There are several dart strings in Flutter's default demo project, such as "Flutter Demo"," Flutter Demo Home Page","You have pushed the button this many times:". If the Dart code is correctly obfuscated, you should not see these strings present in the static analysis tool's report. But unfortunately, it's easy to see them in the IPA package. Oddly enough, the Android APK package doesn't exist, so something is clearly wrong.
Code sample
Flutter‘s default demo project:
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
Additional Information:
Ios/Flutter/Generated. Xcconfig seems to be correct:
The text was updated successfully, but these errors were encountered: