testcookie_refresh_encrypt_cookie

The `testcookie_refresh_encrypt_cookie` directive controls the encryption of the challenge cookie in the NGINX testcookie robot mitigation module.

Syntaxtestcookie_refresh_encrypt_cookie on | off;
Defaultoff
Contexthttp, server, location
Arguments1

Description

The testcookie_refresh_encrypt_cookie directive is used within the context of the NGINX testcookie module to specify whether to encrypt the challenge cookies that are sent to users attempting to access protected resources. When enabled, this directive allows the challenge cookie to be encrypted using AES-128 in CBC mode, providing an additional layer of security against automatic or scripted requests that might try to bypass the challenge-response mechanism. The encryption process requires a user-defined key and initialization vector (IV) to maintain cookie integrity while allowing for client-side decryption through JavaScript.

The primary parameter for this directive is a boolean flag (on/off). When set to 'on', the challenge cookie generated during the user's initial request will be encrypted, making it unreadable by unauthorized users or bots. Conversely, setting it to 'off' means that the challenge cookie will be plain text, which could be more vulnerable to exploitation. However, it is essential to balance usability and security, as encrypted cookies may complicate client-side parsing and debugging processes for legitimate users who may inadvertently face access challenges.

This directive can be configured in various contexts, such as http, server, or location, which allows NGINX administrators to apply cookie encryption according to specific server or location requirements. Properly configuring this directive alongside other related settings (like testcookie_secret) will ensure the integrity and security of user sessions by preventing unauthorized manipulation of cookie values during transmission.

Config Example

http {
    testcookie_refresh_encrypt_cookie on;
}

server {
    location / {
        # Other testcookie configurations
    }
}

Ensure that the encryption parameters (key & IV) are properly configured; otherwise cookies may not be decryptable on the client side.

Using 'off' may expose challenge cookies in plain text, potentially leading to security vulnerabilities.

Remember that cookies need to be decrypted correctly on the client side using JavaScript to maintain functionality.

← Back to all directives