aikido-zen 0.1.1-x86_64-linux → 0.2.0-x86_64-linux

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +1 -0
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +11 -2
  5. data/benchmarks/rails7.1_sql_injection.js +30 -34
  6. data/docs/banner.svg +128 -129
  7. data/docs/config.md +8 -6
  8. data/docs/rails.md +2 -2
  9. data/lib/aikido/zen/agent.rb +3 -1
  10. data/lib/aikido/zen/api_client.rb +3 -3
  11. data/lib/aikido/zen/attack.rb +105 -36
  12. data/lib/aikido/zen/collector/routes.rb +2 -0
  13. data/lib/aikido/zen/collector.rb +19 -3
  14. data/lib/aikido/zen/config.rb +44 -20
  15. data/lib/aikido/zen/errors.rb +10 -1
  16. data/lib/aikido/zen/event.rb +4 -2
  17. data/lib/aikido/zen/libzen-v0.1.37.x86_64.so +0 -0
  18. data/lib/aikido/zen/middleware/check_allowed_addresses.rb +2 -14
  19. data/lib/aikido/zen/middleware/middleware.rb +11 -0
  20. data/lib/aikido/zen/middleware/{throttler.rb → rack_throttler.rb} +3 -11
  21. data/lib/aikido/zen/middleware/request_tracker.rb +190 -0
  22. data/lib/aikido/zen/middleware/set_context.rb +1 -4
  23. data/lib/aikido/zen/payload.rb +2 -0
  24. data/lib/aikido/zen/rails_engine.rb +8 -0
  25. data/lib/aikido/zen/rate_limiter.rb +1 -1
  26. data/lib/aikido/zen/request/schema/builder.rb +0 -2
  27. data/lib/aikido/zen/request/schema/definition.rb +0 -5
  28. data/lib/aikido/zen/request/schema.rb +0 -3
  29. data/lib/aikido/zen/scanners/path_traversal/helpers.rb +65 -0
  30. data/lib/aikido/zen/scanners/path_traversal_scanner.rb +61 -0
  31. data/lib/aikido/zen/scanners/shell_injection/helpers.rb +159 -0
  32. data/lib/aikido/zen/scanners/shell_injection_scanner.rb +62 -0
  33. data/lib/aikido/zen/scanners/sql_injection_scanner.rb +0 -4
  34. data/lib/aikido/zen/scanners/ssrf_scanner.rb +9 -6
  35. data/lib/aikido/zen/scanners.rb +2 -0
  36. data/lib/aikido/zen/sinks/action_controller.rb +26 -12
  37. data/lib/aikido/zen/sinks/file.rb +120 -0
  38. data/lib/aikido/zen/sinks/kernel.rb +73 -0
  39. data/lib/aikido/zen/sinks.rb +8 -0
  40. data/lib/aikido/zen/system_info.rb +1 -1
  41. data/lib/aikido/zen/version.rb +2 -2
  42. data/lib/aikido/zen.rb +14 -1
  43. data/tasklib/bench.rake +3 -2
  44. metadata +16 -8
  45. data/lib/aikido/zen/libzen-v0.1.31.x86_64.so +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71dff796247be7898e6fa9a68e66a0289c3435e45721b21a4e93ca94e486f130
4
- data.tar.gz: c6f2ade140275a39b8371f9068a7b8b4b96666a903248e0d1e54eeab8e85603d
3
+ metadata.gz: f78def42674508f2ae6b4ddfa8c9f76b480e5fac73b066df9ea777f1b81f68f2
4
+ data.tar.gz: 851d854d0827033acd4db4aa2d6cad3a7e405d7d9e1f1b31e26175f43a898923
5
5
  SHA512:
6
- metadata.gz: d8cd7c12e2b35fb7f6be3708345d445e0ba4f92f2c453db3f404ba40c8489ac709d65e710a1660e1ac7139799493a8879944ec996c1af1d29d5487add7cbf221
7
- data.tar.gz: 1283b73ee94eae915fcb7298ed00319fcef545153421dda1512e7f551d81fa003c47c16ce8892eefc8de7b97d3382a245565b72dd305c708fada87305a1f001d
6
+ metadata.gz: e9c02d42ec4334f06e00869c0279fcbb29a491bf4d9f8187708ea2dc6f824123a2ca57f0c60f6c080c6ec50ead687485d139fdc19a750589b98b8949f1e555e7
7
+ data.tar.gz: e18a83a83a8bd1579ac1a43f30de688b4d7f66cf170de1eaf315566c3c9290c2da8846b6756ed5493f23e58bca20cc0751f312f340b51655b4ff927b1333bcaf
data/.simplecov CHANGED
@@ -4,6 +4,7 @@
4
4
  # SimpleCov version, and it doesn't really give us any benefit to run coverage
5
5
  # in separate ruby versions since we don't branch on ruby version in the code.
6
6
  return if RUBY_VERSION < "3.0"
7
+ return if ENV["DISABLE_COVERAGE"] == "true"
7
8
 
8
9
  SimpleCov.start do
9
10
  # Make sure SimpleCov waits until after the tests
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ### Fixed
6
+
7
+ - Avoid an infinite loop when checking for SSRFs in a circular redirects loop.
8
+
5
9
  ## 0.1.1
6
10
 
7
11
  ### Fixed
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ![Zen by Aikido for Ruby](./docs/banner.svg)
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/aikido-zen.svg?icon=si%3Arubygems&style=flat)](https://badge.fury.io/rb/aikido-zen)
4
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
5
+ [![Unit tests](https://github.com/AikidoSec/firewall-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/AikidoSec/firewall-ruby/actions/workflows/main.yml)
6
+ [![Release](https://github.com/AikidoSec/firewall-ruby/actions/workflows/release.yml/badge.svg)](https://github.com/AikidoSec/firewall-ruby/actions/workflows/release.yml)
7
+
3
8
  # Zen, in-app firewall for Ruby | by Aikido
4
9
 
5
10
  Zen, your in-app firewall for peace of mind—at runtime.
@@ -13,8 +18,8 @@ Rails application, for simple installation and zero maintenance.
13
18
 
14
19
  * 🛡️ [SQL injection attacks](https://www.aikido.dev/blog/the-state-of-sql-injections)
15
20
  * 🛡️ [Server-side request forgery (SSRF)](https://github.com/AikidoSec/firewall-node/blob/main/docs/ssrf.md)
16
- * 🛡️ [Command injection attacks](https://owasp.org/www-community/attacks/Command_Injection) (coming soon)
17
- * 🛡️ [Path traversal attacks](https://owasp.org/www-community/attacks/Path_Traversal)
21
+ * 🛡️ [Command injection attacks](https://www.aikido.dev/blog/command-injection-in-2024-unpacked) (coming soon)
22
+ * 🛡️ [Path traversal attacks](https://www.aikido.dev/blog/path-traversal-in-2024-the-year-unpacked) (coming soon)
18
23
  * 🛡️ [NoSQL injection attacks](https://www.aikido.dev/blog/web-application-security-vulnerabilities) (coming soon)
19
24
 
20
25
  Zen operates autonomously on the same server as your Rails app to:
@@ -81,6 +86,10 @@ To block requests, set the `AIKIDO_BLOCK` environment variable to `true`.
81
86
  See [Reporting to Aikido](#reporting-to-your-aikido-security-dashboard) to learn
82
87
  how to send events to Aikido.
83
88
 
89
+ ## Additional configuration
90
+
91
+ [Configure Zen using environment variables for authentication, mode settings, debugging, and more.](https://help.aikido.dev/doc/configuration-via-env-vars/docrSItUkeR9)
92
+
84
93
  ## Reporting to your Aikido Security dashboard
85
94
 
86
95
  > Aikido is your no nonsense application security platform. One central system
@@ -1,8 +1,5 @@
1
1
  import http from 'k6/http';
2
- import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js';
3
- import { check, sleep, fail } from 'k6';
4
- import exec from 'k6/execution';
5
- import { Trend } from 'k6/metrics';
2
+ import {Trend} from 'k6/metrics';
6
3
 
7
4
  const HTTP = {
8
5
  withZen: {
@@ -16,59 +13,58 @@ const HTTP = {
16
13
  }
17
14
 
18
15
  function test(name, fn) {
19
- const duration = tests[name].duration;
20
- const overhead = tests[name].overhead;
21
-
22
16
  const withZen = fn(HTTP.withZen);
23
17
  const withoutZen = fn(HTTP.withoutZen);
18
+ const timeWithZen = withZen.timings.duration;
19
+ const timeWithoutZen = withoutZen.timings.duration;
24
20
 
25
- const timeWithZen = withZen.timings.duration,
26
- timeWithoutZen = withoutZen.timings.duration;
27
-
28
- duration.add(timeWithZen - timeWithoutZen);
21
+ tests[name].delta.add(timeWithZen - timeWithoutZen);
22
+ tests[name].overhead.add(100 * (timeWithZen - timeWithoutZen) / timeWithoutZen)
29
23
 
30
- const ratio = withZen.timings.duration / withoutZen.timings.duration;
31
- overhead.add(100 * (timeWithZen - timeWithoutZen) / timeWithoutZen)
24
+ tests[name].with_zen.add(timeWithZen);
25
+ tests[name].without_zen.add(timeWithoutZen);
32
26
  }
33
27
 
34
- const defaultHeaders = {
35
- "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
36
- };
28
+ function buildTestTrends(prefix) {
29
+ return {
30
+ delta: new Trend(`${prefix}_delta`),
31
+ with_zen: new Trend(`${prefix}_with_zen`),
32
+ without_zen: new Trend(`${prefix}_without_zen`),
33
+ overhead: new Trend(`${prefix}_overhead`)
34
+ };
35
+ }
37
36
 
38
37
  const tests = {
39
- test_post_page_with_json_body: {
40
- duration: new Trend("test_post_page_with_json_body"),
41
- overhead: new Trend("test_overhead_with_json_body")
42
- },
43
- test_get_page_without_attack: {
44
- duration: new Trend("test_get_page_without_attack"),
45
- overhead: new Trend("test_overhead_without_attack")
46
- },
47
- test_get_page_with_sql_injection: {
48
- duration: new Trend("test_get_page_with_sql_injection"),
49
- overhead: new Trend("test_overhead_with_sql_injection"),
50
- }
38
+ test_post_page_with_json_body: buildTestTrends("test_post_page_with_json_body"),
39
+ test_get_page_without_attack: buildTestTrends("test_get_page_without_attack"),
40
+ test_get_page_with_sql_injection: buildTestTrends("test_get_page_with_sql_injection")
51
41
  }
52
42
  export const options = {
53
43
  vus: 1, // Number of virtual users
54
44
  iterations: 200,
55
45
  thresholds: {
56
- test_post_page_with_json_body: ["med<10"],
57
- test_get_page_without_attack: ["med<10"],
58
- test_get_page_with_sql_injection: ["med<10"],
46
+ http_req_failed: ['rate==0'], // we are marking the attacks as expected, so we should have no errors
47
+ test_post_page_with_json_body_delta: ["med<10"],
48
+ test_get_page_without_attack_delta: ["med<10"],
49
+ test_get_page_with_sql_injection_delta: ["med<10"],
59
50
  }
60
51
  };
61
52
 
62
- const expectAttack = http.expectedStatuses(500);
53
+ const expectAttack = http.expectedStatuses(200, 500);
63
54
 
64
55
  export default function () {
65
56
  test("test_post_page_with_json_body",
66
57
  (http) => http.post("/cats", JSON.stringify({cat: {name: "Féline Dion"}}), {
67
- headers: {"Content-Type": "application/json"}
58
+ headers: {
59
+ "Content-Type": "application/json",
60
+ "Accept": "application/json"
61
+ }
68
62
  })
69
63
  )
64
+
70
65
  test("test_get_page_without_attack", (http) => http.get("/cats"))
66
+
71
67
  test("test_get_page_with_sql_injection", (http) =>
72
- http.get("/cats/1'%20OR%20''='", {responseCallback: expectAttack})
68
+ http.get("/cats/1'%20OR%20''='", { responseCallback: expectAttack })
73
69
  )
74
70
  }