For the complete documentation index, see llms.txt. This page is also available as Markdown.

Configuring and Writing Custom Plugins

Updates (July 2026 to September 2026)
  • July 2026

    • Updated the Writing a Custom Plugin section to add information about logging test results. For more information, see Writing a Custom Plugin section, Python Plugin tab, Step 1.

    • Updated the Writing a Custom Plugin section to add a note about the impact of not uploading test results. For more information, see Writing a Custom Plugin section, Python Plugin tab, Step 8.

Custom Plugins allow you to define customized API security tests by configuring how Traceable should mutate requests, validate, and report the identified vulnerabilities. You can write these plugins in YAML or Python according to your requirements.

This topic explains the different ways in which you can configure a custom plugin. It also explains how you can write a Custom YAML or Python Plugin along with the structure, required components, and detailed steps.

Ways to Configure a Custom Plugin

You can configure custom plugins in Traceable in either of the following ways:

  • Traceable platform (Recommended Method)

  • config.yaml file

This section explains the steps to configure a custom plugin using the above options.

This method enables you to create custom Python plugins using the config.yaml file (plugins section) on your local machine. The following are configurations that you can use while creating the plugin:

Default Location — TRACEABLE_HOME

CLI — $HOME/.traceable

Docker — /app/userdata

File Directory
Default Location
Description

config.yaml

$TRACEABLE_HOME

Contains the configuration for AST, such as pre-hooks, post-hooks, and custom plugin definitions.

custom

$TRACEABLE_HOME/plugins/custom

Contains the custom plugin implementations.

hooks

$TRACEABLE_HOME/hooks

Contains the pre- and post-hooks.

testsuite (per API)

$TRACEABLE_HOME/data/<scan_id>/*.json

Contains the JSON files that represent test suites. Each file is a suite of tests generated at the moment for a specific API.

Configuring custom plugins

The following section in the config.yaml file defines the custom plugins to load during the test runs:

In the above code snippet, the plugin name is sample_plugin, which should match the name of the plugin defined in the custom Python plugin code placed in the $TRACEABLE_HOME/plugins/custom directory. For information on the attributes, functions, and operators you can use in a custom Python plugin, see Plugin Functions and Operators. For the steps to write a custom plugin, see Writing a Custom Plugin.

Traceable also provides AI plugins that you can use to detect AI-related issues. In these AI plugins, you can update the prompt key in the config.yaml file using the following code:


Writing a Custom Plugin

You can write Custom Plugins in either YAML or Python, based on your comfort level and use-case complexity. While YAML-based plugins provide a clean and direct declarative approach, the Python-based plugins provide full programmatic control and flexibility over the plugin definition.

In either approach, writing a custom plugin is a multi-step process. The following sections highlight the plugin's scenario and provide its summary.

Scenario: Mass Assignment Vulnerability Detection during User Registration

The below plugin simulates a Mass Assignment attack where it tests whether an attacker can exploit request payloads to gain unauthorized access (admin access) during user registration.

This scenario mirrors a common API security weakness where an unfiltered client-side input leads to unauthorized privilege, and is highlighted in the OWASP API Top 10 under API6:2023 - Unrestricted Access to Sensitive Business Flows.

Following is a summary of the steps in the plugin:

  1. Create a Baseline to verify whether the registration endpoint in your application returns the expected output without any modifications.

  2. Mutate (Modify) the request by adding parameters like admin=true and modifying fields like username and email. This simulates the attempt of an attacker who might suspect that your application code does not validate the user-specified fields against the API schema.

  3. Assert (Validate) the response to check whether the added and modified fields are accepted by the application code and if the registration succeeds unexpectedly.

  4. Send a follow-up request to the endpoint to confirm whether the newly registered user received admin privileges. This final step confirms the presence of the mass assignment vulnerability.

The following tabs highlight the above steps in detail, along with the custom plugin code. Click the tabs according to your requirements and complete the steps to write your custom YAML or Python plugin.

Step 1 — Define the Vulnerability Type and Attributes

Before you create a baseline test, you must define the test name and other attributes as mentioned below.

Step 2 — Adding Baseline Tests

As mentioned above, start by creating a baseline test. This helps you understand the endpoint’s expected behavior before creating the main attack.

Step 3 — Chaining a new test for the attack

Once you have created the above baseline tests, you can now mutate the request and try to trigger a vulnerability. In the below code, tests are chained because they are supposed to be executed only when the above baseline test (Step 2) returns NOT_OK as the result.

Step 4 — Add Mutations to modify the parameters

Now that you have specified the test details, you can specify the mutations and the parameter details to test for the mass assignment vulnerability.

Step 5 — Add Assertions to detect unexpected behavior

Based on the mutated parameters, you can specify the assertions to validate the API response towards the mutated data.

Step 6 — Add another chain for further Admin validation

As part of this step, you add another chain to follow up the above test. Here, Traceable verifies if the admin privileges were actually granted to the mutated user.

Step 7 — Add Mutations to modify parameters for admin validation

Add the mutations as part of the validation test. This test changes the request path and method to check the availability of the admin field for the mutated user above.

Step 7 — Add Assertions to confirm exploitation

This assertion validates whether the vulnerability is successfully exploited using the above attacks.

Combined Custom YAML Plugin

Following is the custom YAML plugin code that combines all the above steps:

Step 1 — Import the Required Modules and Set Up Logging

As part of writing a Custom Python Plugin, you must import its core modules. These modules enable you to create test logic, modify the requests or responses, validate them, define dependency chains, etc.

Step 2 — Define the Plugin Class and Metadata

Define the plugin identity and behavior using the mandatory and optional fields. Some of these fields are used to specify the vulnerability information on the Traceable platform.

Step 3 — Initialize the Plugin

Define the init method to ensure that the plugin has access to scanning APIs and the related metadata.

Step 4 — Set up the Run Method

Define the main execution point of the plugin. The logic below ensures that the plugin runs only once per API per scan. Additionally, on each execution, the plugin populates the logger message, which helps during any debugging.

Step 5 — Create the Baseline Test

Once you have defined the metadata and other methods, start by creating a baseline test. This test helps you understand the endpoint’s expected behavior before creating the main attack. The observed behavior is compared against that observed in the main test.

Add baseline assertions for validation of the following:

  • The ideal response code (${original.http.response.code}) should match the mutated response code (${mutated.http.response.code})

  • The request URL should be the user registration endpoint

Step 6 — Create the Main Attack

Once you have created the above baseline tests, you can now create the main attack that mutates the request and tries to trigger a vulnerability. In this step, tests are chained because they are supposed to be executed only when the above baseline test (Step 5) returns NOT_OK as the result.

Add request mutations. These mutations perform the following:

  • Sets the Admin parameter (${mutated.http.request.body.admin}) to True.

  • Modifies the user email (${mutated.http.request.body.*email}) to a dummy one.

  • Modifies the username (${mutated.http.request.body.*username}) to a dummy one.

Add request assertions for validation of the following:

  • The response body (mutated.http.response.body.status) contains success as the status.

  • The mutated response code (${mutated.http.response.code}) is the same as the original one (${original.http.response.code}).

As mentioned above, chain this main attack to the above baseline test.

Step 7 — Add a Validation Test to Confirm Exploitation

As part of this step, you add another chain to follow up the above test. Here, Traceable verifies if the admin privileges were actually granted to the mutated user. Here, tests are chained because they are supposed to be executed only when the above baseline test (Step 5) returns NOT_OK as the result.

Add request mutations. These mutations perform the following:

  • Modifies the request path (mutated.http.request.path) to retrieve user details.

  • Modifies the request method (mutated.http.request.method) to GET.

Add request assertions for validation of the following:

  • The mutated response code (${mutated.http.response.code}) is the same as the original one (${original.http.response.code}).

  • The response body (${mutated.http.response.body}) contains the admin field as true for the dummy user.

As mentioned above, chain the baseline test with the main attack, and the main attack with the validation test.

Step 8 — Run the Tests and Upload Results

Execute the test and upload the results to the Traceable platform.

Ensure that you call self.upload_result() to upload the test results to the Traceable platform. This provides you with visibility into the findings from a scan.

Combined Custom Python Plugin

Following is the Custom Python Plugin code that combines all the above steps:

Last updated

Was this helpful?