Configuration From v3.0.0
A boolean flag to enable/disable first party mode.
To enable first party mode, you will first need to follow these installation steps.
Default: true
When set, this will modify all first party endpoints to use the configured prefix rather than the default prefix. For example, an application with App ID PX12345678 will have a default first party sensor endpoint of /12345678/init.js and a block script endpoint of /12345678/captcha/captcha.js. If a custom value /botdefense is configured, the sensor endpoint will change to /botdefense/init.js, and the captcha endpoint will change to /botdefense/captcha/captcha.js. The value should start with a slash and have no trailing slash.
If you would like to continue supporting the default first party paths as well as the customized ones, you must have two separate CloudFront behaviors: one for the customized path pattern and one for the default path pattern. Both behaviors should be associated with the same PXFirstParty Lambda function.
Default: Empty
A boolean flag to enable/disable the HUMAN Enforcer.
Default: true
Sets the working mode of the Enforcer.
Possible values:
"monitor" - Monitor Mode"active_blocking" - Blocking ModeDefault: "monitor"
Sets the minimum blocking score of a request.
Possible values:
Default: 100
Like all Lambda Edge functions, HUMAN’s AWS Lambda Enforcer outputs logs to AWS CloudWatch. See here for more information about how to retrieve logs from CloudWatch.
Sets the logging verbosity level. The available options are:
none - no logs will be generatederror - logs only when severe errors occur, best for production environmentsdebug - logs more descriptive messages, helpful for analyzing and debugging the enforcer flowDefault: error
An array of route prefixes and/or regular expressions that trigger a server call to HUMAN servers every time the page is viewed, regardless of viewing history.
Default: Empty
An array of route prefixes and/or regular expressions that are always validated by the HUMAN Worker (as opposed to whitelisted routes).
A regular expression can be defined using new RegExp or directly as an expression, and will be treated as is.
A string value of a path will be treated as a prefix.
Default: Empty
An array of route prefixes and/or regular expressions that are always set to be in monitor mode. This only takes effect when the module is enabled and in blocking mode.
A regular expression can be defined using new RegExp or directly as an expression, and will be treated as is.
A string value of a path will be treated as a prefix.
Default: Empty
An array of route prefixes and/or regular expressions that are always whitelisted and not validated by the HUMAN Worker.
A regular expression can be defined using new RegExp or directly as an expression, and will be treated as is.
A string value of a path will be treated as a prefix.
Default: Empty
An array of user agents constants and/or regular expressions that are always filtered and not validated by the HUMAN middleware.
Default: Empty
An array of IP ranges / IP addresses that are always filtered and not validated by the HUMAN Lambda Function.
Default: Empty
An array of HTTP methods that are always filtered and not validated by the HUMAN Lambda Function.
Default: Empty
An array of headers that are not sent to HUMAN servers on API calls.
Default: [‘cookie’, ‘cookies’]
An array of trusted headers that specify an IP to be extracted.
By default, the value from event.Records[0].cf.request.clientIp is used as the IP.
Default: Empty
If configured headers are insufficient to extract the IP from the request, you may set this value to null and define a custom extraction function with the Extract User IP feature.
A JavaScript function that adds a custom response handler to the request. This function must be set in the custom/custom.js file.
Default: null
The response headers returned should have keys in all lowercase. Currently, the only response headers that can be set are content-type, content-encoding, cache-control, and etag. All other headers will be removed.
JavaScript function that allows interaction with the request data collected by HUMAN before the data is returned to the HUMAN servers. Does not alter the response. This function must be set in the custom/custom.js file.
The context passed into this function contains both the data enrichment object (accessible through the pxde property) as well as a boolean indicating whether the HMAC has been verified (accessible through the pxdeVerified property). See the example below.
Default: null
With the enrich custom parameters function, you can add up to 10 custom parameters to be sent back to HUMAN servers. When set, the function is called before setting the payload on every request to HUMAN servers.
The parameters should be passed according to the correct order (1-10) and their format must align as following: custom_param1, custom_param2, … , custom_param10.
This function must be set in the custom/custom.js file.
Default: null
In case the px_ip_headers configuration isn’t enough to extract the user IP from the incoming request, you can set a custom function to do this. If this function is set, this function is called in order to retrieve the IP from the request. This function must be set in the custom/custom.js file.
The px_ip_headers configuration must be set to null for this function to be called.
Default: null
Allows to change the request context according to a customized logic by modifying other functions, such as Module Mode, Request Sensitivity, etc.
Set the Modify Context function in the custom/custom.js file. Default: null
Here’s a list of all properties on the pxCtx object that can be accessed and modified:
Example
Below, we show how to:
Modifies a custom CSS by adding the CSSRef directive and providing a valid URL to the CSS.
Default: Empty
Adds a custom JS file by adding JSRef directive and providing the JS file that is loaded with the block page.
Default: Empty
The logo is displayed at the top of the the block page.
Max-height = 150px, Width = auto.
Default: Empty
When set, instead of extracting the HUMAN Cookie from the Cookie header, this property specifies a header name that will contain the HUMAN Cookie.
Default: Empty
Allows you to test an enforcer’s blocking flow while you are still in Monitor Mode.
When the header name is set (e.g., x-px-block) and the value is set to 1, when there is a block response (for example from using a User-Agent header with the value of PhantomJS/1.0) the Monitor Mode is bypassed and full block mode is applied. If one of the conditions is missing the block will not apply. This is done per request.
To stay in Monitor Mode, set the header value to 0.
The header name is configurable using the px_bypass_monitor_header property.
Default: Empty
To enable this feature, your Cloudfront distribution must give the Lambda functions access to the request body. You can do this by editing the relevant Lambda Function Associations in the default behavior of your Cloudfront distribution.
You may also need to modify your Origin Request Policy for the Cloudfront distribution to allow the configured value for px_compromised_credentials_header on the origin request. If not, Cloudfront may remove this header before forwarding the request to the origin server.
This feature extracts credentials (hashed username and password) from requests and sends them to HUMAN as additional info in the risk api call. The feature can be toggled on and off, and may be set for any number of unique paths. The settings are adjusted by modifying the pxConfig object in the index.js file.
If credentials are found to be compromised, the header px-compromised-credentials will be added to the origin request with the value 1. You may configure the name of this header with the px_compromised_credentials_header configuration.
Default Values
px_login_credentials_extraction_enabled: false
px_login_credentials_extraction: Empty
px_compromised_credentials_header: “px-compromised-credentials”
It is also possible to define a custom callback to extract the username and password. The function should accept the request object as a parameter and return an object with the keys user and pass. If extraction is unsuccessful, the function should return null.
To enhance detection on login credentials extraction endpoints, the following additional information is sent to HUMAN via an additional_s2s activity:
px_send_raw_username_on_additional_s2s_activity is set to true.This additional_s2s activity can be sent either automatically via the PXActivities Lambda or manually from the origin server using the Additional Activity Header feature.
Rather than using the PXActivities Lambda to send the additional_s2s activity, it is instead possible to generate the base additional_s2s activity along with the URL endpoint, and pass them to the origin server as headers on the original HTTP request. When enabled, the module will add two new headers to the original request and send them to the origin:
px-additional-activity, a stringified JSON activity that should be sent.px-additional-activity-url, the complete URL endpoint to which the JSON object should be sent.If the PXEnforcer Lambda is associated with the viewer-request event, the two header names px-additional-activity and px-additional-activity-url must be added in the CloudFront Origin Request Policy.
Default Values
px_automatic_additional_s2s_activity_enabled: true
px_additional_s2s_activity_header_enabled: false
The px-additional-activity header value is a stringified JSON object that looks like this. Only the fields indicated with // MODIFY should be changed prior to sending. Other fields should not be altered in any way.
After parsing the object and adding the appropriate http_status_code and login_successful fields in the origin server, send the JSON object as an HTTP POST request to the URL provided in the px-additional-activity-url header.
The POST request should be sent with the Content-Type: application/json and Authorization: Bearer <PX_AUTH_TOKEN> headers.
Example Origin Server Behavior
To enable additional_s2s activities as part of credentials intelligence, you will first need to follow these installation steps.
To enable automatic sending of the additional_s2s activity on the PXActivities Lambda, ensure the following configurations are enabled on both the PXEnforcer and PXActivities Lambdas and the login successful reporting method is configured. If left empty, the login successful status will always be reported as false.
The px_additional_s2s_activity_header_enabled configuration must be enabled even using the PXActivities Lambda to automatically send the additional_s2s activity.
Default Values
px_automatic_additional_s2s_activity_enabled: true
px_additional_s2s_activity_header_enabled: false
px_login_successful_reporting_method: Empty
Status
Provide a status or array of statuses that represent a successful login. If a response’s status code matches the provided value or one of the values in the provided array, the login successful status is set to true. Otherwise, it’s set to false.
To define a range of statuses, use the custom reporting method.
Default Values
px_login_successful_status: 200
Header
Provide a header name and value. If the header exists on the response and matches the provided value, the login successful status is set to true. If the header is not found on the response, or if the header value does not match the value in the configuration, the login successful status is set to false.
Default Values
px_login_successful_header_name: x-px-login-successful
px_login_successful_header_value: 1
Custom
Provide a custom callback that returns a boolean indicating if the login was successful. This callback should be set in the custom.js file with the function PerimeterX.SetLoginSuccessfulCustomCallbackFunction().
When enabled, the raw username used for logins on login credentials extraction endpoints will be reported to HUMAN if (1) the credentials were identified as compromised, and (2) the login was successful as reported via the property above.
Default: false
To enable this feature, your Cloudfront distribution must give the Lambda functions access to the request body. You can do this by editing the relevant Lambda Function Associations in the default behavior of your Cloudfront distribution
For those using GraphQL endpoints, it is possible to trigger server-to-server risk calls on particular operation types or names. Like the sensitive routes feature, a request that contains an operation of the configured type or name will trigger a server call to HUMAN servers every time that operation is performed.
If an operation type (e.g., query, mutation) is configured in px_sensitive_graphql_operation_types, all GraphQL operations of that type will be treated as sensitive. If an operation name is configured in px_sensitive_graphql_operation_names, all GraphQL operations with that name will be treated as sensitive.
This feature only applies to requests that contain the string graphql somewhere in the path name.
Default Values:
px_sensitive_graphql_operation_types: Empty
px_sensitive_graphql_operation_names: Empty
Enable the extraction of JWT fields from requests and adding them to the risk, page requested and block activities.
For security reasons, browsers can block cross-origin requests, if they are not allowed by a third-party origin.
CORS is a mechanism that lets the server indicate if a request contains cross-origin resources. It does so by adding special HTTP headers to the request, which allows the browser to load such resources.
In most cases, CORS employs a two-stage procedure with a preliminary request, called preflight, followed by the actual request. The preflight request checks if the actual request will be responded to. To learn more about different request types, see these examples.
The CORS behavior must be configured to address both simple requests (without preflight) and more complex ones (with preflight).
Use the following Enforcer functions to configure CORS:
Here’s an example of how to configure your Enforcer using these functions:
Allows writing your own logic to decide whether the request is sensitive.
The custom sensitive request function gets the request object as a parameter and should return true, otherwise, return false. Throwing an exception is equivalent to `false`.
Default: Empty
A boolean flag to enable/disable decoding url reserved characters.
Default: false