Does anyone has any experience with setting up your own Content Security Policy on NetScaler?
You can enable (and disable) the default CSP header, but this one has some settings that the security department at a customer doesn't like.
You can create your own with a rewrite action/policy (following this guide:
https://docs.netscaler.com/en-us/citrix-adc/current-release/aaa-tm/aaa-rewrite/csp-header.html). But this one doesn't have the nonce key value which is variable.
I found this forum post with an example to fix this with an ns variable:
https://community.citrix.com/forums/topic/258706-trying-to-generate-nonce-header-in-netscaler-version-141-with-random-hash-no-path-in-gui-and-cannot-seem-to-get-it-to-work-in-cli/
I tried the commands in one of the last posts:
_add ns encryptionKey nonce_key -method AES256 -keyValue
64characters -padding ON_
_add ns variable ns_variable_v2_nonce -type "text(1000)" -scope transaction_
_add ns assignment ns_assignment_v1_nonce -variable "$ns_variable_v2_nonce" -set "SYS.RANDOM.TYPECAST_TEXT_T.ENCRYPT(\"nonce_key\")"_
_add rewrite action rw-action-v1-insertnonce insert_http_header X-CSP-Nonce "$ns_variable_v2_nonce"_
_add rewrite action rw-action-v1-cspheader insert_http_header Content-Security-Policy "\"default-src \'self\'; \'nonce- \"+$ns_variable_v2_nonce +\"\'_ (SNIP, no need to include the complete command)
I am unable to call the variable in the creation of the second rewrite action. Every way I try gives a syntax error.
How do you call ns variables in a rewrite action?