Skip to main content
Glama

jwt_vulnerability_check

Analyze JWT tokens for security vulnerabilities like authentication bypass or data leakage using CyberMCP's backend testing protocol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jwt_tokenYesJWT token to analyze for vulnerabilities

Implementation Reference

  • The handler function that analyzes the provided JWT token for common vulnerabilities. It decodes the header and payload, checks the algorithm (e.g., 'none'), expiration, and presence of standard claims like iat, iss, sub.
    async ({ jwt_token }) => {
      try {
        // Split the token
        const parts = jwt_token.split(".");
        if (parts.length !== 3) {
          return {
            content: [
              {
                type: "text",
                text: "Invalid JWT format. Expected 3 parts (header.payload.signature).",
              },
            ],
          };
        }
    
        // Decode header
        const headerBase64 = parts[0];
        const headerJson = Buffer.from(headerBase64, "base64").toString();
        const header = JSON.parse(headerJson);
    
        // Decode payload
        const payloadBase64 = parts[1];
        const payloadJson = Buffer.from(payloadBase64, "base64").toString();
        const payload = JSON.parse(payloadJson);
    
        // Check for security issues
        const issues = [];
    
        // Check algorithm
        if (header.alg === "none") {
          issues.push("Critical: 'none' algorithm used - authentication can be bypassed");
        }
    
        if (header.alg === "HS256" || header.alg === "RS256") {
          // These are generally good, but we'll note it
        } else {
          issues.push(`Warning: Unusual algorithm ${header.alg} - verify if intended`);
        }
    
        // Check expiration
        if (!payload.exp) {
          issues.push("High: No expiration claim (exp) - token never expires");
        } else {
          const expDate = new Date(payload.exp * 1000);
          const now = new Date();
          if (expDate < now) {
            issues.push(`Info: Token expired on ${expDate.toISOString()}`);
          } else {
            const daysDiff = Math.floor((expDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
            if (daysDiff > 30) {
              issues.push(`Medium: Long expiration time (${daysDiff} days) - consider shorter lifetime`);
            }
          }
        }
    
        // Check for missing recommended claims
        if (!payload.iat) {
          issues.push("Low: Missing 'issued at' claim (iat)");
        }
        if (!payload.iss) {
          issues.push("Low: Missing 'issuer' claim (iss)");
        }
        if (!payload.sub) {
          issues.push("Low: Missing 'subject' claim (sub)");
        }
    
        return {
          content: [
            {
              type: "text",
              text: issues.length > 0
                ? `JWT Analysis Results:\n\nHeader: ${JSON.stringify(header, null, 2)}\n\nPayload: ${JSON.stringify(payload, null, 2)}\n\nSecurity Issues:\n${issues.join("\n")}`
                : `JWT Analysis Results:\n\nHeader: ${JSON.stringify(header, null, 2)}\n\nPayload: ${JSON.stringify(payload, null, 2)}\n\nNo security issues detected.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error analyzing JWT: ${(error as Error).message}`,
            },
          ],
        };
      }
    }
  • Zod input schema defining the required 'jwt_token' parameter.
    {
      jwt_token: z.string().describe("JWT token to analyze for vulnerabilities"),
    },
    async ({ jwt_token }) => {
  • Direct registration of the 'jwt_vulnerability_check' tool using server.tool(), including schema and handler, within the registerAuthenticationTools function.
    server.tool(
      "jwt_vulnerability_check",
      {
        jwt_token: z.string().describe("JWT token to analyze for vulnerabilities"),
      },
      async ({ jwt_token }) => {
        try {
          // Split the token
          const parts = jwt_token.split(".");
          if (parts.length !== 3) {
            return {
              content: [
                {
                  type: "text",
                  text: "Invalid JWT format. Expected 3 parts (header.payload.signature).",
                },
              ],
            };
          }
    
          // Decode header
          const headerBase64 = parts[0];
          const headerJson = Buffer.from(headerBase64, "base64").toString();
          const header = JSON.parse(headerJson);
    
          // Decode payload
          const payloadBase64 = parts[1];
          const payloadJson = Buffer.from(payloadBase64, "base64").toString();
          const payload = JSON.parse(payloadJson);
    
          // Check for security issues
          const issues = [];
    
          // Check algorithm
          if (header.alg === "none") {
            issues.push("Critical: 'none' algorithm used - authentication can be bypassed");
          }
    
          if (header.alg === "HS256" || header.alg === "RS256") {
            // These are generally good, but we'll note it
          } else {
            issues.push(`Warning: Unusual algorithm ${header.alg} - verify if intended`);
          }
    
          // Check expiration
          if (!payload.exp) {
            issues.push("High: No expiration claim (exp) - token never expires");
          } else {
            const expDate = new Date(payload.exp * 1000);
            const now = new Date();
            if (expDate < now) {
              issues.push(`Info: Token expired on ${expDate.toISOString()}`);
            } else {
              const daysDiff = Math.floor((expDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
              if (daysDiff > 30) {
                issues.push(`Medium: Long expiration time (${daysDiff} days) - consider shorter lifetime`);
              }
            }
          }
    
          // Check for missing recommended claims
          if (!payload.iat) {
            issues.push("Low: Missing 'issued at' claim (iat)");
          }
          if (!payload.iss) {
            issues.push("Low: Missing 'issuer' claim (iss)");
          }
          if (!payload.sub) {
            issues.push("Low: Missing 'subject' claim (sub)");
          }
    
          return {
            content: [
              {
                type: "text",
                text: issues.length > 0
                  ? `JWT Analysis Results:\n\nHeader: ${JSON.stringify(header, null, 2)}\n\nPayload: ${JSON.stringify(payload, null, 2)}\n\nSecurity Issues:\n${issues.join("\n")}`
                  : `JWT Analysis Results:\n\nHeader: ${JSON.stringify(header, null, 2)}\n\nPayload: ${JSON.stringify(payload, null, 2)}\n\nNo security issues detected.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error analyzing JWT: ${(error as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • High-level registration call to registerAuthenticationTools(server), which includes the jwt_vulnerability_check tool.
    registerAuthenticationTools(server);
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ricauts/CyberMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server