Introducing the SecureFlag Knowledge Base API

The SecureFlag Knowledge Base API connects development tools directly to relevant security training and guidance. It analyzes the text of a feature, ticket, code change, or vulnerability finding to identify associated security risks and return matching hands-on labs and Knowledge Base articles.

Illustration of a panel suggesting three hands-on labs and one article for a ticket called 'Profile picture from a URL.'

How the Knowledge Base API works

Any tool in the development lifecycle can send the API the text it already has, whether that’s a feature description, a Jira story, a pentest finding, or a code snippet. The API identifies the security risks involved and returns the SecureFlag labs that cover them.

Each lab comes with a direct launch link. It opens in a real, fully virtualized desktop in the browser, with the development environment for the relevant language and the vulnerable code ready to find and fix. There’s nothing to install and no catalog to search, so developers can go from a ticket or pull request to practicing the fix in about five seconds.

The API also returns the matching article from the SecureFlag Knowledge Base, both as a web page for developers and as Markdown that an AI agent can load into its context.

There’s no mapping table to maintain or specific input format to follow. The API works out which security risk the submitted text involves and indicates when it doesn’t identify one.

What the API accepts

Each request starts with a piece of text describing the work. It can also include the technology and framework involved, as well as a CWE number if the tool sending the request already has one. The text doesn’t need to mention security at all. The examples below show different kinds of input, from a feature idea to an infrastructure change.

Examples of different API requests

The API uses the same request structure for every type of input, with only the fields changing.

Starting from a feature

Let’s say a team is about to build a new profile feature. All they have is a short description in the backlog, but that’s enough to send:

curl -s -X POST https://knowledge-base-api.secureflag.com/api/content \
  -H "Content-Type: application/json" \
  -d '{
    "token": "<your-api-token>",
    "contexts": [
      {
        "text": "New feature: users can set their profile picture by pasting an image URL. The server fetches the image from that URL and saves it.",
        "technology": "python"
      }
    ]
  }'

The response looks like this:

[
  {
    "kb": "https://knowledge-base.secureflag.com/vulnerabilities/server_side_request_forgery/server_side_request_forgery_in_python_vulnerability.html",
    "kb_markdown": "https://knowledge-base.secureflag.com/_vulnerabilities/server_side_request_forgery/server_side_request_forgery_in_python_vulnerability.md",
    "kb_name": "Server-Side Request Forgery",
    "labs": [
      { "title": "Identify the Origin of SSRF via Avatar Upload", "lab_url": "https://www.secureflag.com/go.html?type=lab&uuid=a9e73cf7-25e4-4f03-bcd1-d03e1e671b0a" },
      { "title": "Server-Side Request Forgery in Avatar Upload", "lab_url": "https://www.secureflag.com/go.html?type=lab&uuid=c36bd7ba-3bf3-4b5e-805e-94dd588d6c4e" },
      { "title": "Server-Side Request Forgery in Agent Screenshot Tool", "lab_url": "https://www.secureflag.com/go.html?type=lab&uuid=429e0c60-d5a7-48b8-9941-f76d907538d1" }
    ]
  }
]

The feature description never mentions security. It describes a server that fetches whatever URL the user supplies, which is the classic setup for server-side request forgery. The API recognizes the risk the feature introduces, and two of the three labs it returns are set in an avatar upload, which is almost the same feature. The developer can practice the fix before writing the code.

A Jira story

{
  "token": "<your-api-token>",
  "contexts": [
    {
      "text": "SHOP-311 As a shopper, I want to search the product catalog by name so that I can find items quickly. AC: the search term is used in the products query; results are sorted by relevance.",
      "technology": "java",
      "framework": "spring"
    }
  ]
}

In the story, “the search term is used in the products query” is enough to point to SQL injection. Unless the query is parameterized, a shopper can type SQL into the search box and have the database run it. 

The labs returned include “Spot the SQL Injection in the Tag Search Filter” and “SQL Injection in Tag Filter Search,” both set in search features much like this one. The SQL Injection in Java article covers the background.

A line of code

{
  "token": "<your-api-token>",
  "contexts": [
    {
      "text": "cmd := exec.Command(\"sh\", \"-c\", \"convert \" + r.FormValue(\"file\") + \" -resize 200x200 thumb.png\")",
      "technology": "go"
    }
  ]
}

A reviewer who spots this line in a pull request gets Go labs such as “Hunt for OS Command Injection” and “Argument Injection in File Backup,” along with the OS Command Injection in Go article.

A pentest finding

{
  "token": "<your-api-token>",
  "contexts": [
    { "text": "Pentest finding: the session token remains valid after the user logs out, and it is not rotated after login." }
  ]
}

Even in a tester’s own words, the finding returns labs such as “Session Not Invalidated On Logout” and “Spot the Reused Unexpired Session,” plus the Broken Session Management article.

A scanner finding with a CWE

{
  "token": "<your-api-token>",
  "contexts": [
    { "cwe": 1321 }
  ]
}

Scanners and SAST tools usually tag their findings with a CWE, and a context can carry it as a number in the optional cwe field. Sometimes the CWE is all an integration has, so it can be sent on its own, without any text. 

This request sends only CWE-1321, a JavaScript weakness that’s far less familiar than SQL injection or cross-site scripting, and gets back the Prototype Pollution article with labs such as “Prototype Pollution Leads to Unauthorized Access” and “Identify the Prototype Pollution.”

When the finding comes with a message, the two can be sent together, and the CWE improves the match. Scanner messages are often generic, such as “User-controlled data flows into this call without sanitization,” which could describe almost any injection flaw.

Add "cwe": 89 and the same message returns SQL Injection, 79 returns Cross-Site Scripting, and 78 returns OS Command Injection.

An infrastructure change

{
  "token": "<your-api-token>",
  "contexts": [
    {
      "text": "Deployment change: run the log-collector container with privileged: true and mount /var/run/docker.sock so it can read logs from every container on the node.",
      "technology": "kubernetes"
    }
  ]
}

A change to a Kubernetes deployment brings back labs such as “Breakout from Privileged Container” and “Privilege Escalation via Docker Group,” as well as the Privilege Escalation article.

Technology and framework support

The same vulnerability looks different in every stack, and so does its fix. That’s why a request can also specify the technology and framework involved, so the results point to labs in the developer’s own stack.

When the request includes the technology, the developer can practice the fix in the language they’ll use, such as a Python lab for a Python team or a Java lab for a Java team. The articles follow the same pattern. 

Technology isn’t limited to programming languages. Contexts can also relate to:

  • Cloud platforms such as AWS, Azure, and GCP

  • Kubernetes, Docker, and CI/CD pipelines

  • Android and iOS apps

  • Mainframe languages such as COBOL and ABAP

  • AI agents and their skills

Behind each one is SecureFlag’s catalog of thousands of labs. If three labs aren’t enough, a request can ask for more, up to 50. That’s useful for building a short learning plan around a single risk.

Supported integration use cases

As the input is plain text, the API fits wherever text is already used in the development process.

  • Issue trackers: An automation rule sends each new story to the API and comments with direct links to the matching labs, so the developer can practice the fix before starting the work.

  • Pull requests: A CI step sends the diff or the changed functions, and a bot posts lab links next to the code under review.

  • Vulnerability management: Each finding from SAST, DAST, or pentest reports is sent as it arrives, with its CWE when the tool provides one, and comes back with the labs for practicing its fix.

  • AI coding agents: An agent can hand the lab links to the developer reviewing its code, and load the article as Markdown into its own context before it writes code.

  • Developer portals and learning platforms: Training can be recommended based on what each team is building, instead of a generic catalog.

As an example, a short Python script can go through a sprint backlog and attach lab links to each story:

import os
import requests

API = "https://knowledge-base-api.secureflag.com/api/content"
TOKEN = os.environ["SECUREFLAG_TOKEN"]


def find_labs(text, technology=None):
    context = {"text": text}
    if technology:
        context["technology"] = technology

    response = requests.post(API, json={"token": TOKEN, "contexts": [context]}, timeout=60)
    response.raise_for_status()
    return response.json()[0]


for story in sprint_stories:
    match = find_labs(f"{story['key']} {story['summary']}\n{story['description']}", technology="java")
    if match is None:
        continue
    print(f"{story['key']}: {match['kb_name']}")
    for lab in match["labs"]:
        print(f"  Lab:       {lab['title']}  {lab['lab_url']}")
    print(f"  Reference: {match['kb']}")

Run against the shop’s backlog, it prints something like this:

SHOP-311: SQL Injection
  Lab:       Spot the SQL Injection in the Tag Search Filter  https://www.secureflag.com/go.html?type=lab&uuid=3cf75010-7ffa-45d2-8a2d-7a36a16971be
  Lab:       SQL Injection in Tag Filter Search  https://www.secureflag.com/go.html?type=lab&uuid=45131d5c-bd37-4c4c-a989-61ce07a60623
  Lab:       SQL Injection by Identifier in Feedback Filter  https://www.secureflag.com/go.html?type=lab&uuid=7d0b3a0d-481c-424e-956d-ea46ab114748
  Reference: https://knowledge-base.secureflag.com/vulnerabilities/sql_injection/sql_injection_in_java_vulnerability.html

Stories with no match are skipped, so the output only lists the work that carries a security risk.

Getting started

The Knowledge Base API is available to SecureFlag customers. Create an API token in the SecureFlag management portal, and any tool that can send a web request can start fetching labs and content for the work going through it.

Connecting development work to hands-on training

SecureFlag helps organizations build secure software with hands-on labs covering more than 75 programming languages and frameworks, automated threat modeling with ThreatCanvas, and structured learning paths by role.

The Knowledge Base API makes this content accessible from the tools teams already use, bringing relevant training into their existing development workflows.

Book a demo to see the Knowledge Base API in action.

Continue reading