tcell_agent 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +9 -22
- data/bin/tcell_agent +127 -132
- data/lib/tcell_agent/agent/event_processor.rb +23 -22
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +7 -7
- data/lib/tcell_agent/agent/policy_manager.rb +20 -15
- data/lib/tcell_agent/agent/policy_types.rb +5 -11
- data/lib/tcell_agent/agent/static_agent.rb +5 -1
- data/lib/tcell_agent/agent.rb +6 -4
- data/lib/tcell_agent/api.rb +7 -9
- data/lib/tcell_agent/appsensor/meta_data.rb +11 -4
- data/lib/tcell_agent/authlogic.rb +3 -3
- data/lib/tcell_agent/cmdi.rb +6 -4
- data/lib/tcell_agent/config/unknown_options.rb +3 -1
- data/lib/tcell_agent/configuration.rb +47 -49
- data/lib/tcell_agent/devise.rb +2 -2
- data/lib/tcell_agent/hooks/login_fraud.rb +58 -29
- data/lib/tcell_agent/instrumentation.rb +11 -10
- data/lib/tcell_agent/logger.rb +2 -2
- data/lib/tcell_agent/patches/meta_data.rb +9 -13
- data/lib/tcell_agent/patches.rb +7 -10
- data/lib/tcell_agent/policies/clickjacking_policy.rb +4 -5
- data/lib/tcell_agent/policies/content_security_policy.rb +6 -12
- data/lib/tcell_agent/policies/dataloss_policy.rb +2 -2
- data/lib/tcell_agent/policies/http_redirect_policy.rb +2 -2
- data/lib/tcell_agent/policies/policy.rb +0 -2
- data/lib/tcell_agent/policies/rust_policies.rb +90 -0
- data/lib/tcell_agent/policies/secure_headers_policy.rb +2 -2
- data/lib/tcell_agent/rails/auth/authlogic.rb +42 -24
- data/lib/tcell_agent/rails/auth/devise.rb +44 -23
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +33 -15
- data/lib/tcell_agent/rails/better_ip.rb +1 -1
- data/lib/tcell_agent/rails/csrf_exception.rb +2 -2
- data/lib/tcell_agent/rails/dlp/process_request.rb +1 -1
- data/lib/tcell_agent/rails/dlp.rb +6 -6
- data/lib/tcell_agent/rails/dlp_handler.rb +1 -1
- data/lib/tcell_agent/rails/js_agent_insert.rb +1 -1
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +1 -1
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +3 -2
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +10 -9
- data/lib/tcell_agent/rails/routes/grape.rb +6 -6
- data/lib/tcell_agent/rails/routes.rb +8 -11
- data/lib/tcell_agent/rust/libtcellagent-0.11.1.dylib +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-0.6.1.so → libtcellagent-0.11.1.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +16 -0
- data/lib/tcell_agent/rust/tcellagent-0.11.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +119 -48
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +17 -20
- data/lib/tcell_agent/sensor_events/command_injection.rb +50 -5
- data/lib/tcell_agent/sensor_events/login_fraud.rb +34 -18
- data/lib/tcell_agent/sensor_events/patches.rb +21 -0
- data/lib/tcell_agent/sensor_events/server_agent.rb +3 -3
- data/lib/tcell_agent/sensor_events/util/utils.rb +4 -3
- data/lib/tcell_agent/servers/puma.rb +2 -2
- data/lib/tcell_agent/servers/unicorn.rb +1 -1
- data/lib/tcell_agent/utils/passwords.rb +28 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/lib/tcell_agent.rb +1 -5
- data/spec/apps/rails-3.2/config/tcell_agent.config +15 -0
- data/spec/apps/rails-3.2/log/development.log +0 -0
- data/spec/apps/rails-3.2/log/test.log +12 -0
- data/spec/apps/rails-4.1/log/test.log +0 -0
- data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +46 -45
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +276 -164
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +44 -47
- data/spec/lib/tcell_agent/api/api_spec.rb +16 -16
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +131 -116
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +55 -51
- data/spec/lib/tcell_agent/cmdi_spec.rb +413 -436
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +145 -128
- data/spec/lib/tcell_agent/configuration_spec.rb +165 -169
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +144 -153
- data/spec/lib/tcell_agent/instrumentation_spec.rb +84 -85
- data/spec/lib/tcell_agent/patches_spec.rb +70 -111
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +313 -244
- data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +28 -28
- data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +643 -513
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +55 -102
- data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +111 -134
- data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +141 -146
- data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +8 -8
- data/spec/lib/tcell_agent/policies/login_policy_spec.rb +15 -17
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +231 -559
- data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +27 -27
- data/spec/lib/tcell_agent/rails/better_ip_spec.rb +30 -34
- data/spec/lib/tcell_agent/rails/logger_spec.rb +50 -49
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +182 -199
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +110 -84
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +107 -85
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +68 -40
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +81 -67
- data/spec/lib/tcell_agent/rails/responses_spec.rb +33 -37
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +116 -121
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +25 -28
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +87 -85
- data/spec/lib/tcell_agent/rails_spec.rb +1 -6
- data/spec/lib/tcell_agent/rust/models_spec.rb +112 -0
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +502 -179
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +44 -33
- data/spec/lib/tcell_agent/sensor_events/dlp_spec.rb +4 -4
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +183 -169
- data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +25 -25
- data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +17 -20
- data/spec/lib/tcell_agent/utils/params_spec.rb +28 -28
- data/spec/lib/tcell_agent/utils/passwords_spec.rb +143 -0
- data/spec/lib/tcell_agent/utils/strings_spec.rb +35 -35
- data/spec/lib/tcell_agent_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -4
- data/spec/support/middleware_helper.rb +10 -10
- data/spec/support/static_agent_overrides.rb +16 -12
- data/tcell_agent.gemspec +17 -33
- metadata +43 -198
- data/LICENSE_libinjection +0 -32
- data/Readme.txt +0 -7
- data/ext/libinjection/extconf.rb +0 -3
- data/ext/libinjection/libinjection.h +0 -65
- data/ext/libinjection/libinjection_html5.c +0 -847
- data/ext/libinjection/libinjection_html5.h +0 -54
- data/ext/libinjection/libinjection_sqli.c +0 -2317
- data/ext/libinjection/libinjection_sqli.h +0 -295
- data/ext/libinjection/libinjection_sqli_data.h +0 -9004
- data/ext/libinjection/libinjection_wrap.c +0 -3525
- data/ext/libinjection/libinjection_xss.c +0 -531
- data/ext/libinjection/libinjection_xss.h +0 -21
- data/lib/tcell_agent/appsensor/injections_matcher.rb +0 -155
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb +0 -49
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb +0 -67
- data/lib/tcell_agent/appsensor/rules/baserules.json +0 -467
- data/lib/tcell_agent/patches/block_rule.rb +0 -93
- data/lib/tcell_agent/patches/sensors_matcher.rb +0 -31
- data/lib/tcell_agent/policies/appsensor/cmdi_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/fpt_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +0 -117
- data/lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb +0 -26
- data/lib/tcell_agent/policies/appsensor/retr_sensor.rb +0 -22
- data/lib/tcell_agent/policies/appsensor/sqli_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor/xss_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor_policy.rb +0 -49
- data/lib/tcell_agent/policies/command_injection_policy.rb +0 -196
- data/lib/tcell_agent/policies/honeytokens_policy.rb +0 -69
- data/lib/tcell_agent/policies/patches_policy.rb +0 -84
- data/lib/tcell_agent/rust/libtcellagent-0.6.1.dylib +0 -0
- data/lib/tcell_agent/rust/tcellagent-0.6.1.dll +0 -0
- data/spec/apps/rails-3.2/Gemfile +0 -25
- data/spec/apps/rails-3.2/Gemfile.lock +0 -126
- data/spec/apps/rails-3.2/Rakefile +0 -7
- data/spec/apps/rails-3.2/app/assets/images/rails.png +0 -0
- data/spec/apps/rails-3.2/app/assets/javascripts/application.js +0 -15
- data/spec/apps/rails-3.2/app/assets/stylesheets/application.css +0 -13
- data/spec/apps/rails-3.2/app/controllers/application_controller.rb +0 -3
- data/spec/apps/rails-3.2/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-3.2/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-3.2/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-3.2/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-3.2/config/application.rb +0 -63
- data/spec/apps/rails-3.2/config/boot.rb +0 -6
- data/spec/apps/rails-3.2/config/environment.rb +0 -5
- data/spec/apps/rails-3.2/config/environments/test.rb +0 -37
- data/spec/apps/rails-3.2/config/routes.rb +0 -11
- data/spec/apps/rails-3.2/config.ru +0 -4
- data/spec/apps/rails-4.1/Gemfile +0 -7
- data/spec/apps/rails-4.1/Gemfile.lock +0 -114
- data/spec/apps/rails-4.1/Rakefile +0 -6
- data/spec/apps/rails-4.1/app/assets/javascripts/application.js +0 -16
- data/spec/apps/rails-4.1/app/assets/stylesheets/application.css +0 -15
- data/spec/apps/rails-4.1/app/controllers/application_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-4.1/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-4.1/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-4.1/config/application.rb +0 -24
- data/spec/apps/rails-4.1/config/boot.rb +0 -4
- data/spec/apps/rails-4.1/config/environment.rb +0 -5
- data/spec/apps/rails-4.1/config/environments/test.rb +0 -41
- data/spec/apps/rails-4.1/config/initializers/assets.rb +0 -8
- data/spec/apps/rails-4.1/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/apps/rails-4.1/config/initializers/cookies_serializer.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/inflections.rb +0 -16
- data/spec/apps/rails-4.1/config/initializers/mime_types.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/session_store.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/wrap_parameters.rb +0 -14
- data/spec/apps/rails-4.1/config/locales/en.yml +0 -23
- data/spec/apps/rails-4.1/config/routes.rb +0 -12
- data/spec/apps/rails-4.1/config/secrets.yml +0 -22
- data/spec/apps/rails-4.1/config.ru +0 -4
- data/spec/controllers/application_controller.rb +0 -12
- data/spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb +0 -522
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +0 -23
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb +0 -159
- data/spec/lib/tcell_agent/patches/block_rule_spec.rb +0 -458
- data/spec/lib/tcell_agent/patches/sensors_matcher_spec.rb +0 -35
- data/spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb +0 -167
- data/spec/lib/tcell_agent/policies/appsensor/retr_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/sqli_sensor_spec.rb +0 -246
- data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +0 -882
- data/spec/lib/tcell_agent/policies/honeytokens_policy_spec.rb +0 -22
|
@@ -6,279 +6,262 @@ module TCellAgent
|
|
|
6
6
|
module Instrumentation
|
|
7
7
|
module Rails
|
|
8
8
|
module Middleware
|
|
9
|
+
regex_policy = {
|
|
10
|
+
'data' => {
|
|
11
|
+
'patterns' => [
|
|
12
|
+
{
|
|
13
|
+
'id' => 'tc-xss-1',
|
|
14
|
+
'pattern' => '(?:<(script|iframe|embed|frame|frameset|' \
|
|
15
|
+
'object|img|applet|body|html|style|layer|link|ilayer|meta|bgsound))',
|
|
16
|
+
'sensor' => 'xss',
|
|
17
|
+
'title' => 'Basic Injection'
|
|
18
|
+
},
|
|
9
19
|
|
|
20
|
+
{
|
|
21
|
+
'id' => 'tc-sqli-1',
|
|
22
|
+
'pattern' => "(?:(?:\\d[\"'`\u00b4\u2019\u2018]\\s+" \
|
|
23
|
+
"[\"'`\u00b4\u2019\u2018]\\s+\\d)|(?:^admin" \
|
|
24
|
+
"\\s*?[\"'`\u00b4\u2019\u2018]|(/\\*)+[\"'`" \
|
|
25
|
+
"\u00b4\u2019\u2018]+\\s?(?:--|#|/\\*|\\{)?)|" \
|
|
26
|
+
"(?:[\"'`\u00b4\u2019\u2018]\\s*?\\b(x?or|div|" \
|
|
27
|
+
'like|between|and)\\b\\s*?[+<>=(),-]\\s*?[\\d"' \
|
|
28
|
+
"'`\u00b4\u2019\u2018])|(?:[\"'`\u00b4\u2019\u2018]" \
|
|
29
|
+
"\\s*?[^\\w\\s]?=\\s*?[\"'`\u00b4\u2019\u2018])|(?:[\"'`" \
|
|
30
|
+
"\u00b4\u2019\u2018]\\W*?[+=]+\\W*?[\"'`\u00b4\u2019\u2018])" \
|
|
31
|
+
"|(?:[\"'`\u00b4\u2019\u2018]\\s*?[!=|][\\d\\s!=+-]+.*?[\"'`" \
|
|
32
|
+
"\u00b4\u2019\u2018(].*?$)|(?:[\"'`\u00b4\u2019\u2018]\\s*?[!=|]" \
|
|
33
|
+
"[\\d\\s!=]+.*?\\d+$)|(?:[\"'`\u00b4\u2019\u2018]\\s*?" \
|
|
34
|
+
"like\\W+[\\w\"'`\u00b4\u2019\u2018(])|(?:\\sis\\s*?0\\W)" \
|
|
35
|
+
"|(?:where\\s[\\s\\w\\.,-]+\\s=)|(?:[\"'`\u00b4\u2019\u2018" \
|
|
36
|
+
"][<>~]+[\"'`\u00b4\u2019\u2018]))",
|
|
37
|
+
'sensor' => 'sqli',
|
|
38
|
+
'title' => 'Basic Injection'
|
|
39
|
+
},
|
|
10
40
|
|
|
11
|
-
|
|
41
|
+
{
|
|
42
|
+
'id' => 'tc-fpt-2',
|
|
43
|
+
'pattern' => '(?:%c0%ae/)|(?:(?:/|\\\\)(conf|usr|etc|proc|opt|s?bin' \
|
|
44
|
+
'|local|dev|tmp|kern|[br]oot|sys|system|windows|winnt|program|' \
|
|
45
|
+
'%[a-z_-]{3,}%)(?:/|\\\\))|(?:(?:/|\\\\)inetpub|localstart\\.asp|' \
|
|
46
|
+
'boot\\.ini)',
|
|
47
|
+
'sensor' => 'fpt',
|
|
48
|
+
'title' => 'Common System Probing'
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
'version' => 1_518_546_622_571
|
|
52
|
+
},
|
|
53
|
+
'policy_id' => 'f3a313b0-10eb-11e8-8080-808080808080',
|
|
54
|
+
'version' => 1
|
|
55
|
+
}
|
|
12
56
|
|
|
57
|
+
class MockAppsensorRackApp
|
|
13
58
|
attr_reader :request_body
|
|
14
59
|
|
|
15
|
-
def initialize(route_id=nil)
|
|
60
|
+
def initialize(route_id = nil)
|
|
16
61
|
@route_id = route_id
|
|
17
62
|
@request_headers = {}
|
|
18
63
|
end
|
|
19
64
|
|
|
20
65
|
def call(env)
|
|
21
66
|
@env = env
|
|
22
|
-
|
|
23
|
-
response_headers = {'Content-Type' => 'text/html'}
|
|
24
|
-
env[
|
|
25
|
-
env[
|
|
26
|
-
#env["tcell.request_data"].route_id = "x-b-c-d-e-f"
|
|
67
|
+
Rack::Request.new(env)
|
|
68
|
+
response_headers = { 'Content-Type' => 'text/html' }
|
|
69
|
+
env['tcell.request_data'].transaction_id = 'a-b-c-d-e-f'
|
|
70
|
+
env['tcell.request_data'].route_id = @route_id
|
|
27
71
|
[200, response_headers, ['OK']]
|
|
28
72
|
end
|
|
29
73
|
|
|
30
74
|
def [](key)
|
|
31
75
|
@env[key]
|
|
32
76
|
end
|
|
33
|
-
|
|
34
77
|
end
|
|
35
78
|
|
|
36
79
|
describe HeadersMiddleware do
|
|
37
|
-
|
|
38
80
|
let(:app) { MockAppsensorRackApp.new }
|
|
39
|
-
let(:app2) { MockAppsensorRackApp.new(
|
|
81
|
+
let(:app2) { MockAppsensorRackApp.new('myrouteid') }
|
|
40
82
|
|
|
41
|
-
subject {
|
|
42
|
-
|
|
43
|
-
context "Appsensor Middleware" do
|
|
44
|
-
before(:all) do
|
|
45
|
-
# need to ensure default rules file is loaded
|
|
46
|
-
AppSensorRuleManager.instance.load_default_rules_file
|
|
47
|
-
end
|
|
83
|
+
subject { with_tcell_middleware(app) }
|
|
48
84
|
|
|
85
|
+
context 'Appsensor Middleware' do
|
|
49
86
|
before(:each) do
|
|
50
87
|
TCellAgent.configuration = TCellAgent::Configuration.new
|
|
51
|
-
TCellAgent.configuration.read_config_from_file(get_test_resource_path(
|
|
88
|
+
TCellAgent.configuration.read_config_from_file(get_test_resource_path('normal_config.json'))
|
|
52
89
|
end
|
|
53
90
|
let(:request) { Rack::MockRequest.new(subject) }
|
|
54
|
-
let(:request2) { Rack::MockRequest.new(
|
|
91
|
+
let(:request2) { Rack::MockRequest.new(with_tcell_middleware(app2)) }
|
|
55
92
|
let(:agent) { ::TCellAgent::Agent.new }
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
|
|
94
|
+
context 'XSS' do
|
|
95
|
+
context 'with allow_payloads = false' do
|
|
58
96
|
before(:each) do
|
|
59
97
|
old_uap = TCellAgent.configuration.allow_payloads
|
|
60
|
-
TCellAgent.configuration.allow_payloads =
|
|
61
|
-
TCellAgent.thread_agent.processPolicyJson(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
TCellAgent.configuration.allow_payloads = true
|
|
99
|
+
TCellAgent.thread_agent.processPolicyJson(
|
|
100
|
+
{
|
|
101
|
+
'regex' => regex_policy,
|
|
102
|
+
'appsensor' => {
|
|
103
|
+
'policy_id' => '153ed270',
|
|
104
|
+
'version' => 2,
|
|
105
|
+
'data' => {
|
|
106
|
+
'options' => {
|
|
107
|
+
'payloads' => {
|
|
108
|
+
'send_payloads' => true,
|
|
109
|
+
'log_payloads' => false
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
'sensors' => {
|
|
113
|
+
'xss' => {
|
|
114
|
+
'dynamic_patterns' => ['tc-xss-1'],
|
|
115
|
+
'patterns' => ['1']
|
|
116
|
+
}
|
|
117
|
+
}
|
|
74
118
|
}
|
|
75
119
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
120
|
+
},
|
|
121
|
+
false
|
|
122
|
+
)
|
|
123
|
+
|
|
78
124
|
TCellAgent.empty_event_queue
|
|
79
125
|
TCellAgent.configuration.allow_payloads = old_uap
|
|
80
126
|
end
|
|
81
|
-
it "alerts on get xss payload" do
|
|
82
|
-
response = request.get("/foo?xyz=%3CSCRIPT%3Ealert(1)%3C%2Fscript%3E", 'REMOTE_ADDR' => '1.3.3.4,3.4.5.6')
|
|
83
|
-
expected_as = {
|
|
84
|
-
"event_type"=>"as",
|
|
85
|
-
"dp"=>"xss",
|
|
86
|
-
"param"=>"xyz",
|
|
87
|
-
"remote_addr"=>"1.3.3.4",
|
|
88
|
-
"m"=>"GET",
|
|
89
|
-
"pattern"=>"1",
|
|
90
|
-
"uri"=>"http://example.org/foo?xyz=",
|
|
91
|
-
"meta"=>{"l" => "query"}}
|
|
92
|
-
expect(TCellAgent.event_queue).to include(expected_as)
|
|
93
|
-
end
|
|
94
127
|
|
|
95
|
-
it
|
|
96
|
-
|
|
128
|
+
it 'alerts on get xss payload' do
|
|
129
|
+
request.get('/foo?xyz=%3CSCRIPT%3Ealert(1)%3C%2Fscript%3E', 'REMOTE_ADDR' => '1.3.3.4,3.4.5.6')
|
|
97
130
|
expected_as = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
'event_type' => 'as',
|
|
132
|
+
'dp' => 'xss',
|
|
133
|
+
'param' => 'xyz',
|
|
134
|
+
'remote_addr' => '1.3.3.4',
|
|
135
|
+
'm' => 'GET',
|
|
136
|
+
'pattern' => 'tc-xss-1',
|
|
137
|
+
'uri' => 'http://example.org/foo?xyz=',
|
|
138
|
+
'meta' => { 'l' => 'query' },
|
|
139
|
+
'payload' => '<SCRIPT>alert(1)</script>'
|
|
140
|
+
}
|
|
106
141
|
expect(TCellAgent.event_queue).to include(expected_as)
|
|
107
|
-
end
|
|
142
|
+
end
|
|
108
143
|
|
|
109
|
-
it
|
|
110
|
-
|
|
144
|
+
it 'alerts on post xss payload' do
|
|
145
|
+
request.post('/foo', :input => 'x=<SCRIPT>alert(1)</SCRIPT>', 'REMOTE_ADDR' => '1.2.3.4,3.4.5.6')
|
|
111
146
|
expected_as = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
'event_type' => 'as',
|
|
148
|
+
'dp' => 'xss',
|
|
149
|
+
'param' => 'x',
|
|
150
|
+
'remote_addr' => '1.2.3.4',
|
|
151
|
+
'm' => 'POST',
|
|
152
|
+
'pattern' => 'tc-xss-1',
|
|
153
|
+
'uri' => 'http://example.org/foo',
|
|
154
|
+
'meta' => { 'l' => 'body' },
|
|
155
|
+
'payload' => '<SCRIPT>alert(1)</SCRIPT>'
|
|
156
|
+
}
|
|
120
157
|
expect(TCellAgent.event_queue).to include(expected_as)
|
|
121
158
|
end
|
|
122
|
-
end
|
|
123
159
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
old_uap = TCellAgent.configuration.allow_payloads
|
|
127
|
-
TCellAgent.configuration.allow_payloads = true
|
|
128
|
-
TCellAgent.thread_agent.processPolicyJson({"appsensor"=>{
|
|
129
|
-
"policy_id" => "153ed270",
|
|
130
|
-
"version" => 2,
|
|
131
|
-
"data" => {
|
|
132
|
-
"options" => {
|
|
133
|
-
"payloads" => {
|
|
134
|
-
"send_payloads" => true,
|
|
135
|
-
"log_payloads" => false
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
"sensors" => {
|
|
139
|
-
"xss" => {
|
|
140
|
-
"patterns" => ["1", "2", "8"]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}}, cache=false)
|
|
145
|
-
TCellAgent.empty_event_queue
|
|
146
|
-
TCellAgent.configuration.allow_payloads = old_uap
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it "checks that payload is sent in xss with route_id" do
|
|
150
|
-
response = request2.get("/foo?xyz=%3Cscript%3Ealert(1)%3C%2Fscript%3E")
|
|
160
|
+
it 'alerts on get xss payload with route_id' do
|
|
161
|
+
request2.get('/foo?xyz=%3Cscript%3Ealert(1)%3C%2Fscript%3E')
|
|
151
162
|
expected_as = {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
'event_type' => 'as',
|
|
164
|
+
'dp' => 'xss',
|
|
165
|
+
'param' => 'xyz',
|
|
166
|
+
'rid' => 'myrouteid',
|
|
167
|
+
'm' => 'GET',
|
|
168
|
+
'pattern' => 'tc-xss-1',
|
|
169
|
+
'uri' => 'http://example.org/foo?xyz=',
|
|
170
|
+
'meta' => { 'l' => 'query' },
|
|
171
|
+
'payload' => '<script>alert(1)</script>'
|
|
172
|
+
}
|
|
162
173
|
expect(TCellAgent.event_queue).to include(expected_as)
|
|
163
174
|
end
|
|
164
175
|
end
|
|
165
|
-
|
|
166
176
|
end
|
|
167
177
|
|
|
168
|
-
context
|
|
178
|
+
context 'SQL Injection' do
|
|
169
179
|
before(:each) do
|
|
170
|
-
TCellAgent.thread_agent.processPolicyJson(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
TCellAgent.thread_agent.processPolicyJson(
|
|
181
|
+
{
|
|
182
|
+
'regex' => regex_policy,
|
|
183
|
+
'appsensor' => {
|
|
184
|
+
'policy_id' => '153ed270',
|
|
185
|
+
'version' => 2,
|
|
186
|
+
'data' => {
|
|
187
|
+
'sensors' => {
|
|
188
|
+
'sqli' => {
|
|
189
|
+
'dynamic_patterns' => ['tc-sqli-1'],
|
|
190
|
+
'patterns' => ['1']
|
|
191
|
+
}
|
|
192
|
+
}
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
195
|
+
},
|
|
196
|
+
false
|
|
197
|
+
)
|
|
187
198
|
TCellAgent.empty_event_queue
|
|
188
199
|
end
|
|
189
200
|
|
|
190
|
-
it
|
|
201
|
+
it 'alerts on get sqli payload' do
|
|
191
202
|
old_uap = TCellAgent.configuration.allow_payloads
|
|
192
203
|
TCellAgent.configuration.allow_payloads = false
|
|
193
204
|
# ' OR '3'='3
|
|
194
|
-
|
|
205
|
+
request.get('/foo?xyz=abds&def=%27%20OR%20%273%27%3D%273', 'REMOTE_ADDR' => '1.3.3.4,3.4.5.6')
|
|
195
206
|
TCellAgent.configuration.allow_payloads = old_uap
|
|
196
207
|
expected_as = {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
'event_type' => 'as',
|
|
209
|
+
'dp' => 'sqli',
|
|
210
|
+
'param' => 'def',
|
|
211
|
+
'remote_addr' => '1.3.3.4',
|
|
212
|
+
'm' => 'GET',
|
|
213
|
+
'pattern' => 'tc-sqli-1',
|
|
214
|
+
'uri' => 'http://example.org/foo?xyz=&def=',
|
|
215
|
+
'meta' => { 'l' => 'query' }
|
|
216
|
+
}
|
|
205
217
|
expect(TCellAgent.event_queue).to include(expected_as)
|
|
206
218
|
end
|
|
207
219
|
end
|
|
208
220
|
|
|
209
|
-
context
|
|
210
|
-
it
|
|
211
|
-
TCellAgent.thread_agent.processPolicyJson(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
response = request.get("/foo?xyz=/ETC/PASSWD", 'REMOTE_ADDR' => '1.3.3.4,3.4.5.6')
|
|
231
|
-
expected_as = {
|
|
232
|
-
"event_type"=>"as",
|
|
233
|
-
"dp"=>"fpt",
|
|
234
|
-
"param"=>"xyz",
|
|
235
|
-
"remote_addr"=>"1.3.3.4",
|
|
236
|
-
"m"=>"GET",
|
|
237
|
-
"pattern"=>"2",
|
|
238
|
-
"uri"=>"http://example.org/foo?xyz=",
|
|
239
|
-
"meta"=>{"l" => "query"}}
|
|
240
|
-
expect(TCellAgent.event_queue).to include(expected_as)
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it "checks that payload is sent" do
|
|
244
|
-
TCellAgent.thread_agent.processPolicyJson({"appsensor"=>{
|
|
245
|
-
"policy_id"=>"153ed270",
|
|
246
|
-
"version" => 2,
|
|
247
|
-
"data"=>{
|
|
248
|
-
"options" => {
|
|
249
|
-
"payloads" => {
|
|
250
|
-
"send_payloads" => true,
|
|
251
|
-
"log_payloads" => false
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
"sensors" => {
|
|
255
|
-
"fpt" => {
|
|
256
|
-
"patterns" => ["1", "2", "3"]
|
|
221
|
+
context 'File Path Traversal' do
|
|
222
|
+
it 'alerts on most obvious payload' do
|
|
223
|
+
TCellAgent.thread_agent.processPolicyJson(
|
|
224
|
+
{
|
|
225
|
+
'regex' => regex_policy,
|
|
226
|
+
'appsensor' => {
|
|
227
|
+
'policy_id' => '153ed270',
|
|
228
|
+
'version' => 2,
|
|
229
|
+
'data' => {
|
|
230
|
+
'options' => {
|
|
231
|
+
'payloads' => {
|
|
232
|
+
'send_payloads' => false,
|
|
233
|
+
'log_payloads' => false
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
'sensors' => {
|
|
237
|
+
'fpt' => {
|
|
238
|
+
'dynamic_patterns' => ['tc-fpt-2'],
|
|
239
|
+
'patterns' => ['2']
|
|
240
|
+
}
|
|
241
|
+
}
|
|
257
242
|
}
|
|
258
243
|
}
|
|
259
|
-
}
|
|
260
|
-
|
|
244
|
+
},
|
|
245
|
+
false
|
|
246
|
+
)
|
|
261
247
|
TCellAgent.empty_event_queue
|
|
262
248
|
|
|
263
|
-
|
|
249
|
+
request.get('/foo?xyz=/ETC/PASSWD', 'REMOTE_ADDR' => '1.3.3.4,3.4.5.6')
|
|
264
250
|
expected_as = {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
251
|
+
'event_type' => 'as',
|
|
252
|
+
'dp' => 'fpt',
|
|
253
|
+
'param' => 'xyz',
|
|
254
|
+
'remote_addr' => '1.3.3.4',
|
|
255
|
+
'm' => 'GET',
|
|
256
|
+
'pattern' => 'tc-fpt-2',
|
|
257
|
+
'uri' => 'http://example.org/foo?xyz=',
|
|
258
|
+
'meta' => { 'l' => 'query' }
|
|
259
|
+
}
|
|
274
260
|
expect(TCellAgent.event_queue).to include(expected_as)
|
|
275
261
|
end
|
|
276
262
|
end
|
|
277
263
|
end
|
|
278
|
-
|
|
279
264
|
end
|
|
280
|
-
|
|
281
|
-
|
|
282
265
|
end
|
|
283
266
|
end
|
|
284
267
|
end
|