# ByteMatchStatementProperty

A rule statement that defines a string match search for AWS WAF to apply to web requests.

The byte match statement provides the bytes to search for, the location in requests that you want AWS WAF to search, and other settings. The bytes to search for are typically a string that corresponds with ASCII characters. In the AWS WAF console and the developer guide, this is called a string match statement.

- Source: Generated at build time
- Type last changed: v2.268.0 · 2 Sep 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_wafv2 as wafv2 } from 'aws-cdk-lib';

declare const all: any;
declare const allQueryArguments: any;
declare const method: any;
declare const queryString: any;
declare const singleHeader: any;
declare const singleQueryArgument: any;
declare const uriPath: any;
const byteMatchStatementProperty: wafv2.CfnRuleGroup.ByteMatchStatementProperty = {
  fieldToMatch: {
    allQueryArguments: allQueryArguments,
    body: {
      oversizeHandling: 'oversizeHandling',
    },
    cookies: {
      matchPattern: {
        all: all,
        excludedCookies: ['excludedCookies'],
        includedCookies: ['includedCookies'],
      },
      matchScope: 'matchScope',
      oversizeHandling: 'oversizeHandling',
    },
    headerOrder: {
      oversizeHandling: 'oversizeHandling',
    },
    headers: {
      matchPattern: {
        all: all,
        excludedHeaders: ['excludedHeaders'],
        includedHeaders: ['includedHeaders'],
      },
      matchScope: 'matchScope',
      oversizeHandling: 'oversizeHandling',
    },
    ja3Fingerprint: {
      fallbackBehavior: 'fallbackBehavior',
    },
    ja4Fingerprint: {
      fallbackBehavior: 'fallbackBehavior',
    },
    jsonBody: {
      matchPattern: {
        all: all,
        includedPaths: ['includedPaths'],
      },
      matchScope: 'matchScope',

      // the properties below are optional
      invalidFallbackBehavior: 'invalidFallbackBehavior',
      oversizeHandling: 'oversizeHandling',
    },
    method: method,
    queryString: queryString,
    singleHeader: singleHeader,
    singleQueryArgument: singleQueryArgument,
    uriFragment: {
      fallbackBehavior: 'fallbackBehavior',
    },
    uriPath: uriPath,
  },
  positionalConstraint: 'positionalConstraint',
  textTransformations: [{
    priority: 123,
    type: 'type',
  }],

  // the properties below are optional
  preParseTextTransformations: [{
    priority: 123,
    type: 'type',
  }],
  searchString: 'searchString',
  searchStringBase64: 'searchStringBase64',
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_wafv2 as wafv2

# all: Any
# all_query_arguments: Any
# method: Any
# query_string: Any
# single_header: Any
# single_query_argument: Any
# uri_path: Any

byte_match_statement_property = wafv2.CfnRuleGroup.ByteMatchStatementProperty(
    field_to_match=wafv2.CfnRuleGroup.FieldToMatchProperty(
        all_query_arguments=all_query_arguments,
        body=wafv2.CfnRuleGroup.BodyProperty(
            oversize_handling="oversizeHandling"
        ),
        cookies=wafv2.CfnRuleGroup.CookiesProperty(
            match_pattern=wafv2.CfnRuleGroup.CookieMatchPatternProperty(
                all=all,
                excluded_cookies=["excludedCookies"],
                included_cookies=["includedCookies"]
            ),
            match_scope="matchScope",
            oversize_handling="oversizeHandling"
        ),
        header_order=wafv2.CfnRuleGroup.HeaderOrderProperty(
            oversize_handling="oversizeHandling"
        ),
        headers=wafv2.CfnRuleGroup.HeadersProperty(
            match_pattern=wafv2.CfnRuleGroup.HeaderMatchPatternProperty(
                all=all,
                excluded_headers=["excludedHeaders"],
                included_headers=["includedHeaders"]
            ),
            match_scope="matchScope",
            oversize_handling="oversizeHandling"
        ),
        ja3_fingerprint=wafv2.CfnRuleGroup.JA3FingerprintProperty(
            fallback_behavior="fallbackBehavior"
        ),
        ja4_fingerprint=wafv2.CfnRuleGroup.JA4FingerprintProperty(
            fallback_behavior="fallbackBehavior"
        ),
        json_body=wafv2.CfnRuleGroup.JsonBodyProperty(
            match_pattern=wafv2.CfnRuleGroup.JsonMatchPatternProperty(
                all=all,
                included_paths=["includedPaths"]
            ),
            match_scope="matchScope",

            # the properties below are optional
            invalid_fallback_behavior="invalidFallbackBehavior",
            oversize_handling="oversizeHandling"
        ),
        method=method,
        query_string=query_string,
        single_header=single_header,
        single_query_argument=single_query_argument,
        uri_fragment=wafv2.CfnRuleGroup.UriFragmentProperty(
            fallback_behavior="fallbackBehavior"
        ),
        uri_path=uri_path
    ),
    positional_constraint="positionalConstraint",
    text_transformations=[wafv2.CfnRuleGroup.TextTransformationProperty(
        priority=123,
        type="type"
    )],

    # the properties below are optional
    pre_parse_text_transformations=[wafv2.CfnRuleGroup.PreParseTextTransformationProperty(
        priority=123,
        type="type"
    )],
    search_string="searchString",
    search_string_base64="searchStringBase64"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.wafv2.*;

Object all;
Object allQueryArguments;
Object method;
Object queryString;
Object singleHeader;
Object singleQueryArgument;
Object uriPath;

ByteMatchStatementProperty byteMatchStatementProperty = ByteMatchStatementProperty.builder()
        .fieldToMatch(FieldToMatchProperty.builder()
                .allQueryArguments(allQueryArguments)
                .body(BodyProperty.builder()
                        .oversizeHandling("oversizeHandling")
                        .build())
                .cookies(CookiesProperty.builder()
                        .matchPattern(CookieMatchPatternProperty.builder()
                                .all(all)
                                .excludedCookies(List.of("excludedCookies"))
                                .includedCookies(List.of("includedCookies"))
                                .build())
                        .matchScope("matchScope")
                        .oversizeHandling("oversizeHandling")
                        .build())
                .headerOrder(HeaderOrderProperty.builder()
                        .oversizeHandling("oversizeHandling")
                        .build())
                .headers(HeadersProperty.builder()
                        .matchPattern(HeaderMatchPatternProperty.builder()
                                .all(all)
                                .excludedHeaders(List.of("excludedHeaders"))
                                .includedHeaders(List.of("includedHeaders"))
                                .build())
                        .matchScope("matchScope")
                        .oversizeHandling("oversizeHandling")
                        .build())
                .ja3Fingerprint(JA3FingerprintProperty.builder()
                        .fallbackBehavior("fallbackBehavior")
                        .build())
                .ja4Fingerprint(JA4FingerprintProperty.builder()
                        .fallbackBehavior("fallbackBehavior")
                        .build())
                .jsonBody(JsonBodyProperty.builder()
                        .matchPattern(JsonMatchPatternProperty.builder()
                                .all(all)
                                .includedPaths(List.of("includedPaths"))
                                .build())
                        .matchScope("matchScope")

                        // the properties below are optional
                        .invalidFallbackBehavior("invalidFallbackBehavior")
                        .oversizeHandling("oversizeHandling")
                        .build())
                .method(method)
                .queryString(queryString)
                .singleHeader(singleHeader)
                .singleQueryArgument(singleQueryArgument)
                .uriFragment(UriFragmentProperty.builder()
                        .fallbackBehavior("fallbackBehavior")
                        .build())
                .uriPath(uriPath)
                .build())
        .positionalConstraint("positionalConstraint")
        .textTransformations(List.of(TextTransformationProperty.builder()
                .priority(123)
                .type("type")
                .build()))

        // the properties below are optional
        .preParseTextTransformations(List.of(PreParseTextTransformationProperty.builder()
                .priority(123)
                .type("type")
                .build()))
        .searchString("searchString")
        .searchStringBase64("searchStringBase64")
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.WAFv2;

var all;
var allQueryArguments;
var method;
var queryString;
var singleHeader;
var singleQueryArgument;
var uriPath;

var byteMatchStatementProperty = new ByteMatchStatementProperty {
    FieldToMatch = new FieldToMatchProperty {
        AllQueryArguments = allQueryArguments,
        Body = new BodyProperty {
            OversizeHandling = "oversizeHandling"
        },
        Cookies = new CookiesProperty {
            MatchPattern = new CookieMatchPatternProperty {
                All = all,
                ExcludedCookies = new [] { "excludedCookies" },
                IncludedCookies = new [] { "includedCookies" }
            },
            MatchScope = "matchScope",
            OversizeHandling = "oversizeHandling"
        },
        HeaderOrder = new HeaderOrderProperty {
            OversizeHandling = "oversizeHandling"
        },
        Headers = new HeadersProperty {
            MatchPattern = new HeaderMatchPatternProperty {
                All = all,
                ExcludedHeaders = new [] { "excludedHeaders" },
                IncludedHeaders = new [] { "includedHeaders" }
            },
            MatchScope = "matchScope",
            OversizeHandling = "oversizeHandling"
        },
        Ja3Fingerprint = new JA3FingerprintProperty {
            FallbackBehavior = "fallbackBehavior"
        },
        Ja4Fingerprint = new JA4FingerprintProperty {
            FallbackBehavior = "fallbackBehavior"
        },
        JsonBody = new JsonBodyProperty {
            MatchPattern = new JsonMatchPatternProperty {
                All = all,
                IncludedPaths = new [] { "includedPaths" }
            },
            MatchScope = "matchScope",

            // the properties below are optional
            InvalidFallbackBehavior = "invalidFallbackBehavior",
            OversizeHandling = "oversizeHandling"
        },
        Method = method,
        QueryString = queryString,
        SingleHeader = singleHeader,
        SingleQueryArgument = singleQueryArgument,
        UriFragment = new UriFragmentProperty {
            FallbackBehavior = "fallbackBehavior"
        },
        UriPath = uriPath
    },
    PositionalConstraint = "positionalConstraint",
    TextTransformations = new [] { new TextTransformationProperty {
        Priority = 123,
        Type = "type"
    } },

    // the properties below are optional
    PreParseTextTransformations = new [] { new PreParseTextTransformationProperty {
        Priority = 123,
        Type = "type"
    } },
    SearchString = "searchString",
    SearchStringBase64 = "searchStringBase64"
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

var all interface{}
var allQueryArguments interface{}
var method interface{}
var queryString interface{}
var singleHeader interface{}
var singleQueryArgument interface{}
var uriPath interface{}

byteMatchStatementProperty := &ByteMatchStatementProperty{
	FieldToMatch: &FieldToMatchProperty{
		AllQueryArguments: allQueryArguments,
		Body: &BodyProperty{
			OversizeHandling: jsii.String("oversizeHandling"),
		},
		Cookies: &CookiesProperty{
			MatchPattern: &CookieMatchPatternProperty{
				All: all,
				ExcludedCookies: []*string{
					jsii.String("excludedCookies"),
				},
				IncludedCookies: []*string{
					jsii.String("includedCookies"),
				},
			},
			MatchScope: jsii.String("matchScope"),
			OversizeHandling: jsii.String("oversizeHandling"),
		},
		HeaderOrder: &HeaderOrderProperty{
			OversizeHandling: jsii.String("oversizeHandling"),
		},
		Headers: &HeadersProperty{
			MatchPattern: &HeaderMatchPatternProperty{
				All: all,
				ExcludedHeaders: []*string{
					jsii.String("excludedHeaders"),
				},
				IncludedHeaders: []*string{
					jsii.String("includedHeaders"),
				},
			},
			MatchScope: jsii.String("matchScope"),
			OversizeHandling: jsii.String("oversizeHandling"),
		},
		Ja3Fingerprint: &JA3FingerprintProperty{
			FallbackBehavior: jsii.String("fallbackBehavior"),
		},
		Ja4Fingerprint: &JA4FingerprintProperty{
			FallbackBehavior: jsii.String("fallbackBehavior"),
		},
		JsonBody: &JsonBodyProperty{
			MatchPattern: &JsonMatchPatternProperty{
				All: all,
				IncludedPaths: []*string{
					jsii.String("includedPaths"),
				},
			},
			MatchScope: jsii.String("matchScope"),

			// the properties below are optional
			InvalidFallbackBehavior: jsii.String("invalidFallbackBehavior"),
			OversizeHandling: jsii.String("oversizeHandling"),
		},
		Method: method,
		QueryString: queryString,
		SingleHeader: singleHeader,
		SingleQueryArgument: singleQueryArgument,
		UriFragment: &UriFragmentProperty{
			FallbackBehavior: jsii.String("fallbackBehavior"),
		},
		UriPath: uriPath,
	},
	PositionalConstraint: jsii.String("positionalConstraint"),
	TextTransformations: []interface{}{
		&TextTransformationProperty{
			Priority: jsii.Number(123),
			Type: jsii.String("type"),
		},
	},

	// the properties below are optional
	PreParseTextTransformations: []interface{}{
		&PreParseTextTransformationProperty{
			Priority: jsii.Number(123),
			Type: jsii.String("type"),
		},
	},
	SearchString: jsii.String("searchString"),
	SearchStringBase64: jsii.String("searchStringBase64"),
}
```

## Properties

- `fieldToMatch`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRuleGroup.FieldToMatchProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_wafv2.CfnRuleGroup.FieldToMatchProperty.html) (required) — The part of the web request that you want AWS WAF to inspect.

- `positionalConstraint`: string (required) — The area within the portion of the web request that you want AWS WAF to search for `SearchString` .

  Valid values include the following:

  *CONTAINS*

  The specified part of the web request must include the value of `SearchString` , but the location doesn't matter.

  *CONTAINS_WORD*

  The specified part of the web request must include the value of `SearchString` , and `SearchString` must contain only alphanumeric characters or underscore (A-Z, a-z, 0-9, or _). In addition, `SearchString` must be a word, which means that both of the following are true:

  - `SearchString` is at the beginning of the specified part of the web request or is preceded by a character other than an alphanumeric character or underscore (_). Examples include the value of a header and `;BadBot` .
  - `SearchString` is at the end of the specified part of the web request or is followed by a character other than an alphanumeric character or underscore (_), for example, `BadBot;` and `-BadBot;` .

  *EXACTLY*

  The value of the specified part of the web request must exactly match the value of `SearchString` .

  *STARTS_WITH*

  The value of `SearchString` must appear at the beginning of the specified part of the web request.

  *ENDS_WITH*

  The value of `SearchString` must appear at the end of the specified part of the web request.

- `preParseTextTransformations`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRuleGroup.PreParseTextTransformationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_wafv2.CfnRuleGroup.PreParseTextTransformationProperty.html)[]

- `searchString`: string — A string value that you want AWS WAF to search for.

  AWS WAF searches only in the part of web requests that you designate for inspection in `FieldToMatch` . The maximum length of the value is 200 bytes. For alphabetic characters A-Z and a-z, the value is case sensitive.

  Don't encode this string. Provide the value that you want AWS WAF to search for. AWS CloudFormation automatically base64 encodes the value for you.

  For example, suppose the value of `Type` is `HEADER` and the value of `Data` is `User-Agent` . If you want to search the `User-Agent` header for the value `BadBot` , you provide the string `BadBot` in the value of `SearchString` .

  You must specify either `SearchString` or `SearchStringBase64` in a `ByteMatchStatement` .

- `searchStringBase64`: string — String to search for in a web request component, base64-encoded.

  If you don't want to encode the string, specify the unencoded value in `SearchString` instead.

  You must specify either `SearchString` or `SearchStringBase64` in a `ByteMatchStatement` .

- `textTransformations`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRuleGroup.TextTransformationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_wafv2.CfnRuleGroup.TextTransformationProperty.html)[] (required) — Text transformations eliminate some of the unusual formatting that attackers use in web requests in an effort to bypass detection.

  If you specify one or more transformations in a rule statement, AWS WAF performs all transformations on the content of the request component identified by `FieldToMatch` , starting from the lowest priority setting, before inspecting the content for a match.
