Skip to content

Proof of Concept Insights - Avoid overwrite of Function.prototype.toString() #6

@bentobox19

Description

@bentobox19

PoC

https://github.com/LavaMoat/docs/blob/main/react-native-and-ses-lockdown.md

Discussion

The following error

 ERROR  failed to delete intrinsics.%FunctionPrototype%.toString.prototype [TypeError: Unable to delete property.]

Is tracked to sentry assigning to Function.prototype.toString. This is a System Integration.

FunctionToString.prototype.setupOnce = function () {
    // eslint-disable-next-line @typescript-eslint/unbound-method
    originalFunctionToString = Function.prototype.toString;
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    Function.prototype.toString = function() {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        var context = this.__sentry_original__ || this;
        return originalFunctionToString.apply(context, args);
    };
};

From https://docs.sentry.io/platforms/javascript/configuration/integrations/default/

System integrations are enabled by default to integrate into the standard library or the interpreter itself. They are documented so you can be both aware of what they do and disable them if they cause issues.

From https://docs.sentry.io/platforms/react-native/configuration/options/

integrations
In some SDKs, the integrations are configured through this parameter on library initialization. For more information, please see our documentation for a specific integration.

defaultIntegrations
This can be used to disable integrations that are added by default. When set to false, no default integrations are added.

Disable default integrations in sentry

diff --git a/app/util/setupSentry.js b/app/util/setupSentry.js
index 7b633ec0..a98c1b5a 100644
--- a/app/util/setupSentry.js
+++ b/app/util/setupSentry.js
@@ -18,6 +18,7 @@ export default function setupSentry() {
                dsn,
                debug: __DEV__,
                environment,
+              defaultIntegrations: false,
                integrations: [
                        new Dedupe(),
                        new ExtraErrorData(),

Items of Action

  • Understand the impact on the MetaMask Mobile App product of removing these default integrations.
  • Generate an alternative plan if the removal of such option is not viable for any reason.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions