Akto - API Security platform
Akto WebsiteStart freeBook a demoDiscordGitHub
  • Github Open Source Repo
  • What is Akto?
  • AktoGPT
  • AGENTIC AI
    • Akto MCP Server
  • Getting Started
    • Deployment Types
    • Akto Cloud
      • Connect Akto with Hybrid SaaS
      • Migrate From Self Hosted Setup To SaaS
      • Setting up proxy
    • Akto Self Hosted
      • AWS deploy
        • AWS multi-VPC deploy
        • AWS Cross-Region Cross-VPC deploy
        • Custom subdomain on Akto on AWS
      • Helm Deploy
      • Azure Deploy
      • Openshift Deploy
      • Heroku
      • GCP Deploy
    • Local Deploy
    • FAQs on data concerns
  • Traffic Connector
    • Traffic Data Sources
    • eBPF
      • Connect Akto with eBPF
      • Connect Akto with eBPF on mTLS
    • Kubernetes
      • Connect Akto with Kubernetes in AWS
      • Connect Akto eBPF with Kubernetes
    • API Gateways
      • Connect Akto with Envoy
      • Connect Akto with NGINX
      • Connect Akto with Istio
      • Connect Akto with HAProxy
      • Connect Akto with Azure API Management
      • Connect Akto with F5
      • Connect Akto with 3Scale
      • Connect Akto with Layer7 API Gateway
      • Connect Akto with Citrix
      • Connect Akto with Kong
      • Connect Akto with Kong Mesh
      • Connect Akto with Cloudflare
      • Connect Akto with IBM Connect
      • Connect Akto with Mulesoft Flex Gateway
      • Connect Akto with Apigee
    • Mirroring
      • Connect Akto with AWS Traffic Mirroring
      • Connect Akto with GCP Packet Mirroring
    • AWS Services
      • Connect Akto with AWS Beanstalk
      • Connect Akto with AWS API Gateway
      • Connect Akto with AWS Lambda
      • Connect Akto with AWS API Gateway with CloudWatch OAM
      • Connect Akto with AWS API Gateway with service account (Temporary Credentials)
      • Connect Akto with AWS Fargate
      • Connect Akto with AWS EKS
      • Connect Akto with AWS ECS
    • GCP Services
      • Connect Akto with GCP Packet Mirroring
      • Connect Akto with Apigee
      • Connect Akto with Google Cloud Run Functions
      • Connect Akto with Google Cloud Run
      • Connect Akto with GKE
    • Azure Services
      • Connect Akto with Azure App Services
      • Connect Akto with Azure API Management
      • Connect Akto with AKS
      • Connect Akto with Azure OpenShift
      • Connect Akto with Azure Container App
      • Connect Akto with Azure Functions
    • Akto SDK
    • Source Code
      • GitHub
      • Bitbucket
      • GitLab
      • API inventory from source code
      • Source code installation
    • Virtual Machines
      • Connect Akto with Docker
      • Connect Akto on TLS service
      • Connect Akto with TCP Agent
    • Manual
      • Connect Akto with Burp suite
      • Connect Akto with Postman
      • Connect Akto with OpenAPI
      • Add API traffic to Akto using HAR file upload
      • API Import: WSDL in Akto
    • Configure TLS on kafka
  • API Inventory
    • Concepts
      • API Endpoints
      • Meta Properties of API Endpoint
      • API Collection
      • Explore mode
      • Data Types
      • API Groups
      • Environment Type
      • Protocol Support in Akto
      • API Changes
      • Third Party APIs
      • Tags
      • API Dependency Graph
      • Sensitive Data
      • Alerts
      • Shadow APIs
      • Zombie APIs
      • Risk Score
      • Auth types
      • Access Type
      • API discovery from source code
      • Advanced Filter Option
    • How-To
      • Enable Tree view for API collections
      • Export an API Collection to Postman
      • Export an API Collection to Burp
      • Create API group
      • Collection-Based RBAC
      • Descriptions for API Collections & Endpoints
      • Remove API(s) from API group
      • Deactivate an API Collection
      • Add collection using Explore Mode
      • De-merge API
      • Create Swagger File Using Akto
      • Copy API Endpoints Data
      • Add an API Collection
      • Set environment type
      • Delete an API Collection
      • Create a Custom Data Type
      • Reset Data Types in Akto
      • Set Sensitivity of a Data Type
      • De-activate a data type
      • Add a Custom Auth Type
      • Reset an Auth Type
      • Configure Access Types
      • View New API Endpoint
      • Add Private CIDRs list
      • View New Parameters
      • Configure alerts on API changes
      • Create a custom collection
      • Redact sensitive data
      • Extract APIs from github hosted source code using our Github Action
      • Extract APIs from source code using our Docker based CLI
      • Remove Bad Endpoints
      • Create New Tags
      • Edit Tags
  • API Protection
    • Overview
    • Concepts
      • Threat Policy
  • WAF
    • AWS WAF
    • Cloudflare WAF
  • Test Editor
    • Concepts
      • Overview
      • Test YAML
      • Test Library
      • Custom Test
      • Test YAML Syntax (Detailed)
        • ID
        • Info
        • Wordlists
        • Auth
        • API Selection Filters
        • Execute
        • Validation
        • Contexts
        • Strategy
        • Conditional flows
      • Template YAMLs
        • Local File Inclusion with Akto
      • Dynamic severity
    • How To
      • Edit Test
      • Create a Custom Test
      • Deactivate Test
      • Play in Test Editor Background
      • Copy Test Content
      • Opening Endpoint in Test Editor
      • Add a New Test Library
      • Contribute to Test Library
  • API Security Testing
    • Concepts
      • Severity Levels
      • Test
      • Result types
      • Test Role
      • User Config
      • Test Result
      • JSON Recording for Automated Auth Tokens
    • How To
      • Run Test
      • Auto-Create Jira Tickets
      • Edit Test Settings
      • Install testing module in your Cloud
        • Ephemeral Storage for Hybrid Runtime
        • gRPC Testing in Hybrid Testing Module
      • Create Custom Test Suites
      • Recalculate Issue Counts
      • Testing Module Selector in Akto
      • Run Tests by Category
      • Export Vulnerability Report from Test Results
      • Test Multiple APIs
      • Schedule Tests
      • Stop Tests
      • Run Test on Any One Endpoint
      • Configure global rate limit
      • Rescan Specific Issues Resolved
      • Configure Pre-request Script
      • Set Up JSON Recording for Auth Tokens
      • Create a Test Role
      • Edit Auth Flow in Test Roles
      • Restrict Access to a Test Role Using RBAC
      • Play in Test Editor Playground
      • Conduct Role-Based Testing
      • Run tests in CLI using Akto
      • Secure GraphQL APIs using Akto
      • Secure REST APIs using Akto
      • Secure SOAP APIs using Akto
      • Create and Edit Auth Types
  • Issues
    • Concepts
      • Overview
      • Values
      • Vulnerability Report
      • Remediation
    • How To
      • Jira Integration
      • Azure DevOps Boards Integration
      • Triage Issues
        • Review Issues Marked as False Positives
      • Export Selected Issues to Reports
      • Export Vulnerability Report
  • CI/CD
    • GitHub Actions
      • Create GitHub App
    • Jenkins
    • Azure DevOps
    • GitLab
    • Generic CI/CD
    • How To
      • Run tests in CI/CD
      • Add test to CI/CD Pipeline
      • Get API Credentials
      • Test ID from Akto test
  • Account
    • Invite User
      • Change role of a User
    • Create a New Account
    • How to Switch Between Accounts in Akto
    • Understanding Role Permissions
    • Custom roles
    • Audit Logs
    • SSO
      • Azure AD SAML
      • Okta OIDC
      • Github OIDC
      • Google Workspace SSO
      • Add Members From SSO
  • Compliance
    • Concepts
      • Overview
  • API security posture
    • Concepts
      • Overview
  • SIEM Integration
    • Splunk
  • Alerts
    • Slack Webhook
    • Microsoft Teams Webhook
    • Setup alerts for Akto test run results
  • Pricing
    • Pricing Plans
    • How To
      • Upgrade Your Plan
      • Downgrade Your Plan
      • Sync Usage Data
  • API reference
    • API reference
  • Components
    • Dashboard
    • Testing module
    • Traffic mirroring module
    • Runtime analyzer
    • Context analyzer
    • Puppeteer server
    • Other OSS
    • robots.txt
  • Troubleshooting
    • How to get logs
    • How to disable logging
    • How to update helm deployments
  • Stay Updated on New Releases
  • Support
Powered by GitBook
On this page
  • Syntax
  • add_body_param
  • modify_body_param
  • delete_body_param
  • replace_body
  • add_header
  • modify_header
  • delete_header
  • add_query_param
  • modify_query_param
  • delete_query_param
  • modify_url
  • modify_method
  • remove_auth_header
  • replace_auth_header
  • follow_redirect
  • attach_file
  • jwt_replace_body
  • Combining multiple conditions in Execute
  • Sample Yaml -

Was this helpful?

  1. Test Editor
  2. Concepts
  3. Test YAML Syntax (Detailed)

Execute

After determining that an endpoint is eligible for a YAML Test, it is forwarded to the execution step. This section is used to describe actions/modifications to achieve the desired test request body.

Syntax

Execute operators can be of the following types -

Operator
Description

add_body_param

Add a new key/value pair in the request payload at the root

modify_body_param

Modify value of an existing key in the request payload at any position. If the key is missing, executor engine ignores the step and moves on to next operation

delete_body_param

Delete an existing key in the request payload at any position. If the key is missing, executor engine ignores the step and moves on to next operation

replace_body

Replace the entire request body with the supplied input

add_header

Add a new key/value pair in the request headers

modify_header

Modify value of an existing header key in the request headers. If the header key is missing, executor engine ignores the step and moves on to next operation

delete_header

Delete an existing header key in the request headers. If the header key is missing, executor engine ignores the step and moves on to next operation

add_query_param

Add a new key/value pair in the query params

modify_query_param

Modify value of an existing key in the query params. If the key is missing, executor engine ignores the step and moves on to next operation

delete_query_param

Delete an existing key in the query params. If the key is missing, executor engine ignores the step and moves on to next operation

modify_url

Modify url to desired value. Supports entire url replacement, as well as replacing just a substring

modify_method

Modify http method to desired method value

remove_auth_header

Remove Auth Headers in the request headers. If auth headers are missing, this operation throws an error and aborts the test for the endpoint

replace_auth_header

Replace the auth header by headers in User config section. If you are using JWT tokens, you can replace them too using JWT-specific instructions

follow_redirect

Specify whether the test attempt should follow redirect or not. By default follow redirect is set to $true$

attach_file

Replaces the request body by the contents of the file

jwt_replace_body

Replace JWT body with given content

add_body_param

Used for adding a new key/value pair in the request payload at the root. This takes 2 params, key and value.

Example 1

Original request body of the endpoint you are trying to test:

Original request body
{
  "user": "John Doe",
  "email": "johndoe@example.com"
}

Let’s say we want to add key (”status”) with value → “admin”

Sample Yaml to modify request body

Sample yaml to modify request
execute:
	add_body_param:
		status: admin

Modified request body of the endpoint you are trying to test:

Modified request body
{
  "user": "John Doe",
  "email": "johndoe@example.com",on
	"status": "admin"
}

modify_body_param

Used for modifying value of an existing key in the request payload at any position. If the key is missing, executor engine ignores the step and moves on to next operation. This takes 2 params, key and value.

Example 1

Original request body of the endpoint you are trying to test:

Original request body
{
  "user": "John Doe",
  "email": "johndoe@example.com"
}

Let’s say we want to modify key (”user”) with value → “admin”

Sample Yaml to modify request body

Sample yaml to modify body
execute:
  type: single
  requests:
    - req: 	
			-	modify_body_param:
					user: admin

Modified request body of the endpoint you are trying to test:

Modified request body
{
  "user": "admin",
  "email": "johndoe@example.com"
}

delete_body_param

Used for deleting an existing key in the request payload at any position. If the key is missing, executor engine ignores the step and moves on to next operation. This takes single param, key.

Example 1

Original request body of the endpoint you are trying to test:

original body request
{
  "user": "John Doe",
  "email": "johndoe@example.com"
	"isActive": false
}

Let’s say we want to remove key (”isActive”)

Sample Yaml to modify request body

Sample yaml to modify body
execute:
  type: single
  requests:
    - req: 	
				- delete_body_param: isActive

Modified request body of the endpoint you are trying to test:

Modified request body
{
  "user": "admin",
  "email": "johndoe@example.com"
}

replace_body

Used for replacing the entire request body with the supplied input. This takes 1 param, new payload.

Original request body of the endpoint you are trying to test:

original req body
{
  "user": "John Doe",
  "email": "johndoe@example.com",
	"isActive": false
}

Let’s say we want to replace the above payload with below new payload

new payload
{
		"id": 5,
		"admin": true
}

Sample Yaml to modify request body

Modified request body
execute:
  type: single
  requests:
    - req: 	
			 - replace_body: '{"id": 5, "admin": true}'

add_header

Used for adding a new key/value pair in the request headers. This takes 2 params, key and value.

Example 1

original header of the endpoint you are trying to test:

original API header
Content-Type: application/json
Authorization: <Bearer-Token>

Let’s say we want to add a new header (”Host”) with value → “xyz.evil.com”

Sample Yaml to modify request header

Sample yaml to modify header
execute:
  type: single
  requests:
    - req: 
				- add_header:
						Host: xyz.evil.com

Modified request header of the endpoint you are trying to test:

modified header
Content-Type: application/json
Authorization: <Bearer-Token>
Host: xyz.evil.com

modify_header

Used for modifying value of an existing header key in the request headers. If the header key is missing, executor engine ignores the step and moves on to next operation. This takes 2 params, key and value.

Example

original header of the endpoint you are trying to test:

Content-Type: application/json
Authorization: <Bearer-Token>

Let’s say we want to modify key (”Authorization”) with a different user token value →

Sample Yaml to modify request header

jsexecute:
  type: single
  requests:
    - req: 
				- modify_header:
						Authorization: <Bearer-Token2>

Modified request header of the endpoint you are trying to test:

Content-Type: application/json
Authorization: <Bearer-Token2>

delete_header

Used for deleting an existing header key in the request headers. If the header key is missing, executor engine ignores the step and moves on to next operation. This takes a single param, key.

Example 1

original header of the endpoint you are trying to test:

Content-Type: application/json
Authorization: <Bearer-Token>

Let’s say we want to modify key (”Authorization”) with a different user token value →

Sample Yaml to delete request header

execute:
  type: single
  requests:
    - req: 	
				- delete_header: Authorization

Modified request header of the endpoint you are trying to test:

Content-Type: application/json

add_query_param

Used for adding a new key/value pair in the query params. This takes 2 params, key and value.

Example 1

original url of the endpoint you are trying to test:

http://xyz.com?user=1

Let’s say we want to add a new query param (”admin”) with value → true

Sample Yaml to add query params

execute:
  type: single
  requests:
    - req: 
			- add_query_param:
					admin: true

New query params in the url of the endpoint you are trying to test:

http://xyz.com?user=1&admin=true

modify_query_param

Used for modifying value of an existing key in the query params. If the key is missing, executor engine ignores the step and moves on to next operation. This takes 2 params, key and value.

Example 1

original url of the endpoint you are trying to test:

http://xyz.com?user=1

Let’s say we want to modify query param (”user”) with value → 4

Sample Yaml to modify query params

execute:
  type: single
  requests:
    - req: 
				- modify_query_param:
						user: 4

modified query params in the url of the endpoint you are trying to test:

http://xyz.com?user=4

delete_query_param

Used for deleting an existing key in the query params. If the key is missing, executor engine ignores the step and moves on to next operation. This takes single params, key.

Example 1

original url of the endpoint you are trying to test:

http://xyz.com?user=1&active=true

Let’s say we want to delete query param (”active”)

Sample Yaml to modify query params

execute:
  type: single
  requests:
    - req: 	
			- delete_query_param: active

modified query params in the url of the endpoint you are trying to test:

http://xyz.com?user=1

modify_url

Used for modifying url to desired value. Supports entire url replacement, as well as replacing just a substring.

Replace entire url

original url of the endpoint you are trying to test:

http://xyz.com/api/v1/user

Let’s say you want to replace this with the below url -

http://xyz.evil.com/api/v2/users

Sample Yaml to modify url

execute:
  type: single
  requests:
    - req: 
				- modify_url: http://xyz.evil.com/api/v2/users

Replace based on regex

original url of the endpoint you are trying to test:

http://xyz.com/api/v2/user

Let’s say i just want to replace v2 with v1 in the above url -

Sample Yaml to modify url

execute:
  type: single
  requests:
    - req: 
      - modify_url:
          regex_replace:
            regex: v[\d+]/
            replace_with: v1/

👉🏻 **In simple language:** The above yaml syntax is modifying request url by replacing specified regex string match with v1/

modified url of the endpoint you are trying to test:

http://xyz.com/api/v1/user

Insert token in url

You can use token_insert to insert a token (Eg 123) in the url.

eg. if you want to convert /api/v1/user/orders to /api/v1/user/123/orders, you can do:

  - modify_url:
      token_insert:
        location: 4
        replace_with: 123

Replace token in url

You can use token_replace to insert a token (Eg 123) in the url.

eg. if you want to convert /api/v1/user/456/orders to /api/v1/user/123/orders, you can do:

  - modify_url:
      token_replace:
        location: 4
        replace_with: 123

modify_method

Used for modifying http method to desired method value. This takes a single param, new method value.

Example 1

original url of the endpoint you are trying to test:

POST http://xyz.com/api/v1/user

Let’s say we want to modify method value to PUT

Sample Yaml to modify method

execute:
  type: single
  requests:
    - req: 
      - modify_method: PUT

modified url of the endpoint you are trying to test:

PUT http://xyz.com/api/v1/user

remove_auth_header

Used for Removing Auth Headers in the request headers. If auth headers are missing, this operation throws an error and aborts the test for the endpoint. (Refer to Auth section for better understanding on how auth headers are picked by yaml execution engine.)

Example 1

original headers of the endpoint you are trying to test:

Content-Type: application/json
Authorization: <Bearer-Token>

Let’s say we want to remove the auth header for the test request(in this case auth header is - “Authorization”). Prerequisite: the auth has to be configured in auth types in the dashboard for the below execute section to identify authorization key.

Sample Yaml to remove auth headers

execute:
  type: single
  requests:
    - req: 	
				- remove_auth_header: true

modified headers of the endpoint you are trying to test:

Content-Type: application/json

replace_auth_header

Used in many tests where we need to replace the auth header and inject a malicous auth header instead. This flag removes all the auth headers (including custom auth types) before adding malicious auth headers.

Example 1 - replace auth token by attacker's token

This assumes you have set attacker credentials in User config section.

Sample YAML to replace headers by attacker's tokens

execute:
  type: single
  requests:
    - req:
	- replace_auth_header : true

modified headers will now look like:

Authorization: Bearer attacker.token.here

Example 2 - modify JWT auth token

Used in Broken Authentication tests to exploit JWT-related vulnerabilities. For example, invalidating signature, setting algo to None etc. Possible values are

  • ${auth_context.none_algo_token} - modify JWT token and set algo=NONE

  • ${auth_context.invalid_signature_token} - modify JWT token and make signature invalid (by appending extra characters to signature)

  • ${auth_context.jku_added_token} - modify JWT token by adding a JKU parameter in headers

  • ${auth_context.jwk_added_token} - modify JWT token by adding JWK-related parameters in headers

  • ${auth_context.kid_added_token} - modify JWT token by adding kid parameter in headers

Sample YAML to use the above instructions -

execute:
  type: single
  requests:
    - req:
	- replace_auth_header : ${auth_context.invalid_signature_token}

Modifies the headers by invalidating signature

Authorization: Bearer eyJewqafsd.eafsdzcx.some_invalid_signature_here

follow_redirect

Used for specifying whether the test attempt should follow redirect or not, in case the response received if of redirect type. By default follow redirect is set to true. This takes a single boolean argument(true/false)

Sample Yaml ****For Disabling Redirect

execute:
  type: single
  requests:
    - req:
	- follow_redirect: false

attach_file

Used to replace the request body by the contents of the file. This is useful for APIs that take file an input. Users can test such APIs by passing files with malicious content.

Sample Yaml for attach_file

execute:
  type: single
  requests:
    - req:
        - attach_file: https://some.url.here/file.pdf

jwt_replace_body

Used to replace the jwt body. This just replaces the payload. It keeps headers and signature the same as original JWT token

Sample yaml

execute:
  type: single
  requests:
  - req:
    - jwt_replace_body: ey.new_body.new_signature

Modified token looks like -

Authorization: ey.new_body.old_signature

Combining multiple conditions in Execute

Let’s see a few examples on how we can combine multiple execution operations into a test -

Example 1

Scenario -

  1. add body_param (”status”) with value → “admin” in request payload

  2. modify Request Method To Post

  3. delete QueryParam with key (”userId”)

Sample Yaml -

execute:
	type: single
  requests:
    - req:
      - add_body_param:
      	  status: admin
      - modify_method: POST
      - delete_query_param: userId

Example 2

Scenario -

  1. delete auth header from request

  2. add Header (”origin”) with value → xyz.evil.com

Sample Yaml -

auth:
  authenticated: true
execute:
  type: single
  requests:
    - req:
        - delete_auth_header: true
        - add_header:
            origin: xyz.evil.com 
        - delete_query_param: userId

PreviousAPI Selection FiltersNextValidation

Last updated 1 year ago

Was this helpful?