Overview
Custom CWE protocols let your organization tailor Mend’s built-in SAST detection logic to better match your codebase. You can browse supported CWE protocols, create organization-specific custom versions with modified rules or completely custom CWEs.
Use Protocol Customization when you want to adjust SAST detection to your needs without opening a support request or waiting for a global rule change.
You can also create and test protocol changes from your AI coding agent through the Mend MCP server. See Customize Protocols with an AI Coding Agent.
CWE Detection Protocols
Mend provides built-in CWE detection protocols for supported languages. In some environments, a built-in rule may need tuning: for example, to reduce false positives, support an internal framework, or make the detection logic stricter for your organization’s security standards.
With custom CWE protocols, security teams can create and manage their own versions of Mend SAST’s built-in protocols while keeping the original Mend SAST version available for reference or an easy rollback. When a custom version exists, Mend SAST applies that custom protocol during scans for your organization.
How Custom Protocols Work
The built-in Mend protocol remains unchanged. When you create a custom version, Mend SAST preserves the original protocol and creates a new organization-specific version that you can edit.
After the custom protocol is saved and made the default, it takes precedence over the built-in protocol during scans for your organization. This allows your team to tune detection behavior while still keeping the Mend SAST default available as a baseline.
What You Can Do
-
Browse all built-in CWE protocols supported by Mend.
-
Filter protocols by language, CWE ID, or protocol name.
-
See whether your organization already has a custom version of a protocol.
-
Create a custom version of any built-in protocol.
-
Edit the files that make up the custom protocol directly in the product, with syntax highlighting where available.
-
Validate protocol changes and review clear error or warning messages.
-
Review version history and revert to a previous custom protocol version when needed.
-
Describe a detection gap to your AI coding agent and let it write, validate, and test the protocol change through the Mend MCP server.
How to Customize a CWE Protocol
Getting Started
As an organization administrator, navigate to Administration → Custom CWEs
In the Custom CWEs page, you can manage custom detection rules for each language. The active version is the one used during scans. Select a version to view its rules, or create a new version based on an existing one.
Note that you cannot edit existing rules or add a new CWE while viewing the active version:
Click the Create from Template button:
Alternatively, select a version from the list and then “Use as Template” from its Actions menu:
Once a template has been created, you can set it as the active version via its Actions menu:
Furthermore, the option to add or edit CWEs becomes available.
Add and Edit CWEs
Click the + Add CWE button to create a custom CWE.
Step 1 - Details
Fill in the new CWE’s details:
-
CWE Number (digits only, without leading zeros, e.g., 79)
-
CWE Name (letters, digits and underscores)
-
Severity (High / Medium / Low)
Click Next to proceed.
Step 2 - Detection Rules
Edit existing or add new rule files
Click the Update button at the bottom right corner when done.
Similar to adding a new CWE, you can edit an existing CWE by selecting Edit from its Actions menu:
Custom CWEs are initially in draft mode so that they will not take effect while you are still working on them. Set them as active when you are ready.
CWE Customization Steps Recap
-
Open the built-in protocol to inspect its files in read-only mode.
-
Select the option to create a custom version.
-
Edit the protocol files in the in-product editor.
-
Review any validation messages and resolve errors before continuing.
-
Switch an edited CWE from Draft to Active when you are done.
-
Save the custom version when you are satisfied with the behavior.
Customize Protocols with an AI Coding Agent
Note: This capability is being rolled out gradually and may not be available in your organization yet. Until it is, you can customize protocols in the Mend Platform as described in How to Customize a CWE Protocol.
Instead of editing protocol files by hand, you can describe a detection gap in plain language to an AI coding agent that is connected to the Mend MCP server. The agent reads your code, writes the protocol change, validates it, tests it locally with the Mend CLI, and creates a new custom version that you can review and activate.
For details about the Mend MCP server and the AI coding agents and IDEs it supports, see Mend Agentic Integrations.
The work is done by your own agent and its model. Your source code is not sent to Mend: the Mend MCP server provides the protocol reference, validates the protocol text, and stores the new version.
This feature uses AI. The use of the service indicated under this page is subject to the terms and conditions set forth under our AI Supplemental Terms-of-Service.
Prerequisites
-
Mend account with SAST entitlement on the Mend Platform
-
An AI coding agent that supports the Model Context Protocol (MCP), connected to the Mend MCP server. See Mend Agentic Integrations for setup instructions.
-
The agent must run where it can read the project, for example, in your IDE or terminal. You do not have to start it from the project root, but it needs access to the project folder.
-
Organization administrator permissions.
Step 1 - Describe the Detection Gap
Tell the agent what Mend SAST should detect. You can point at a specific method or describe a new vulnerability class. For example:
Treat Session.request as an SSRF sink
Report CSV injection when user input is written with csv.writer
Step 2 - The Agent Writes and Validates the Protocol
The agent retrieves the protocol reference from the Mend MCP server, inspects the relevant code, and writes the protocol file. It then sends the protocol text to the Mend MCP server for validation and fixes any errors that are returned.
When validation passes, the agent uploads the protocol as a new Inactive version (the agent calls it a template). The new version is based on your currently active version, so earlier customizations are kept. An inactive version does not change your organization's scans.
Step 3 - Review the Test Result
The agent copies the relevant code into a small test snippet and scans it with the Mend CLI twice: once with the default rules and once with the new version. The scan runs offline with only the relevant language engine. The agent then shows a line-by-line comparison, so you can confirm that the missed finding is now reported and that code which should stay unreported is still unreported.
You do not need to install the Mend CLI in advance. If it is missing, the agent downloads it.
The agent also reports the ID of the new version and the command to scan with it yourself. Keep the ID: the agent's working files are temporary, and the version is what holds the rule.
Step 4 - Scan Your Project (Optional)
The agent asks for permission to scan the whole project with the new version. The scan runs locally and offline, nothing is uploaded, and your organization's scans and rules do not change. When the scan finishes, the agent summarizes what is now reported in your own code.
Step 5 - Review the New Version in the Mend Platform
The new version appears under Administration → Custom CWEs with the status Inactive and a description written by the agent. In the rules list, a built-in CWE that the agent changed is marked Mend (Modified), and a CWE that the agent created is marked Custom.
Select Edit from the CWE's Actions menu to view the rule files exactly as the agent wrote them. Files added by the agent are marked Custom.
Step 6 - Activate the Version
When you are satisfied with the results, approve the agent's request to activate the version. Activation applies to every Mend SAST scan of that language across all projects in your organization, starting with the next scan. You can also activate the version, or switch back to a previous one, from the Custom CWEs page.
Example: Add a New CWE
The same flow works for a vulnerability class that Mend SAST does not cover out of the box. In this example, the agent was asked to report CSV injection. It created a new CWE with its own name, type and severity, defined the sink and the sanitizer, and listed the limits of the rule it wrote.
Note: The name and type of a new CWE cannot be changed after the version is created. Review them in the agent's summary before you activate the version.
Testing Protocol Changes
Usually you do not want to roll out changes to the whole organization before thoroughly verifying their impact on some sample projects. Before setting a version as active, you can reference its version id in the CLI via the --scan-rules-id parameter to bypass the currently active version (either the Mend default or a previously customized version) and analyze the project with your newly created version.
When you customize protocols with an AI coding agent, the agent runs this test for you and reports the version ID that it used. See Customize Protocols with an AI Coding Agent.
Version History and Auditability
Each custom protocol version is tracked so your team can review previous changes and revert when necessary. Version IDs are available for use in CLI-based workflows, and protocol changes are logged for audit purposes.
Limitations
-
Customizations are managed at the organization level.
-
Protocol Customization, including customization with an AI coding agent, is only available for Gen 2 languages. See Supported Languages and Frameworks | Gen 2 Engines.
-
A custom version always applies to the whole organization. To control where a new CWE applies, use your code scan configurations: for example, turn the CWE off in a configuration with organization scope and turn it on in a configuration that is assigned to specific applications. See Customize your Code Scan Configuration.
-
Protocols cannot detect weaknesses that the scan engine does not support, such as logic-based weaknesses.
-
A protocol can add or adjust sources, sinks, and sanitizers, and define new CWEs. It cannot add missing entry points, which are defined by the scan engine.
-
The quality of a protocol written by an AI coding agent depends on the model the agent uses. Mend recommends a high-capability model, for example, Claude Sonnet or higher.