Skip to content

Commit 33484be

Browse files
authored
added risk_cookie_max_iterations config (#45)
* added risk_cookie_max_iterations config * minimal number of risk cookie iterations - 500
1 parent 6aa18ea commit 33484be

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
- Added support for bypass monitor header
1717
- Added support for extracting vid from _pxvid cookie
1818
- Added support for rate limit
19+
- Added risk_cookie_max_iterations configuration
1920

2021
### Fixed
2122
- Updated dependencies

lib/perimeterx/configuration.rb

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,29 @@ class Configuration
88
attr_accessor :PX_DEFAULT
99

1010
PX_DEFAULT = {
11-
:app_id => nil,
12-
:cookie_key => nil,
13-
:auth_token => nil,
14-
:module_enabled => true,
15-
:challenge_enabled => true,
16-
:encryption_enabled => true,
17-
:blocking_score => 100,
18-
:sensitive_headers => ["http-cookie", "http-cookies"],
19-
:api_connect_timeout => 1,
20-
:api_timeout => 1,
21-
:max_buffer_len => 10,
22-
:send_page_activities => true,
23-
:send_block_activities => true,
24-
:sdk_name => PxModule::SDK_NAME,
25-
:debug => false,
26-
:module_mode => PxModule::MONITOR_MODE,
27-
:local_proxy => false,
28-
:sensitive_routes => [],
29-
:whitelist_routes => [],
30-
:ip_headers => [],
31-
:ip_header_function => nil,
32-
:bypass_monitor_header => nil
11+
:app_id => nil,
12+
:cookie_key => nil,
13+
:auth_token => nil,
14+
:module_enabled => true,
15+
:challenge_enabled => true,
16+
:encryption_enabled => true,
17+
:blocking_score => 100,
18+
:sensitive_headers => ["http-cookie", "http-cookies"],
19+
:api_connect_timeout => 1,
20+
:api_timeout => 1,
21+
:max_buffer_len => 10,
22+
:send_page_activities => true,
23+
:send_block_activities => true,
24+
:sdk_name => PxModule::SDK_NAME,
25+
:debug => false,
26+
:module_mode => PxModule::MONITOR_MODE,
27+
:local_proxy => false,
28+
:sensitive_routes => [],
29+
:whitelist_routes => [],
30+
:ip_headers => [],
31+
:ip_header_function => nil,
32+
:bypass_monitor_header => nil,
33+
:risk_cookie_max_iterations => 5000
3334
}
3435

3536
def initialize(params)

lib/perimeterx/internal/payload/perimeter_x_payload.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def decrypt(px_cookie)
108108
px_cookie = px_cookie.gsub(' ', '+')
109109
salt, iterations, cipher_text = px_cookie.split(':')
110110
iterations = iterations.to_i
111+
if (iterations > @px_config[:risk_cookie_max_iterations] || iterations < 500)
112+
return
113+
end
111114
salt = Base64.decode64(salt)
112115
cipher_text = Base64.decode64(cipher_text)
113116
digest = OpenSSL::Digest::SHA256.new

0 commit comments

Comments
 (0)