Self Defending

Potency High
Resilience High
Cost High
Tags: rasp, tampering, debugging


Self Defending protects functions and object literals concealing their logic, blocking code tampering attempts with anti-tampering techniques, and detecting debuggers to trigger defenses that thwart reverse engineering attempts. Countermeasures can be specified (optionally) to be executed when someone tries to debug or tamper with the code.

Note: if you intend to minify your code after protecting it with Jscrambler, make sure that the tolerateMinification flag is enabled in your application. This makes it so that the modifications done by this process are not treated as malicious by this and other transformations. We nonetheless recommend that you use Jscrambler after minifying your code, as the last step of your build process, for optimum results. You can learn more about how to configure your application here.

Code Annotation Example

// @jscrambler define selfDefending {threshold: 10480, options: [tolerateBenignPoisoning], countermeasures: {deleteCookies: 1, redirect: /logout}} as sd
// @jscrambler enable sd

Option Types

Name Required Default Value Description
threshold No 10240 Minimum size (in bytes) that a function / object literal must have to be targeted by the transformation.
options No [] List of available options
countermeasures No {"deleteCookies": false,"realTimeNotifications": false,"selfDestruct": false} List of available countermeasures


Name Description
tolerateBenignPoisoning Blocks only malicious native function poisoning


Name Description
customCallback Name of the function to be called as a countermeasure.
deleteCookies Deletes all the cookies accessible via JavaScript.
redirect Redirects the user to a specific URL.
realTimeNotifications Sends a notification when a violation occurs.
selfDestruct Attempts to damage the state and behavior of the application and/or the environment that is running the application.

Browser Compatibility

Browser Compatible Versions Tested Versions Notes
Chrome 50+ 50+
Firefox 50+ 40+
Internet Explorer 8+ 8+
Microsoft Edge 18+ 18+
Safari 9.1+ 9.1+

API Parameters


  "keys": {
    "accessKey": "XXXXXX",
    "secretKey": "YYYYYY"
  "applicationId": "ZZZZZZ",
  "params": [
      "name": "selfDefending",
      "options": {
        "threshold": 10240,
        "options": [],
        "countermeasures": {
          "customCallback": null,
          "deleteCookies": false,
          "redirect": null,
          "realTimeNotifications": false,
          "selfDestruct": false