pwn 0.5.702 → 0.5.703
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/etc/default_skills/pwn/ai/agent/tool_guard/SKILL.md +1 -0
- data/lib/pwn/ai/agent/loop.rb +6 -2
- data/lib/pwn/ai/agent/tool_guard.rb +24 -13
- data/lib/pwn/version.rb +1 -1
- data/spec/lib/pwn/ai/agent/tools/ruby_eval_spec.rb +13 -0
- data/third_party/pwn_rdoc.jsonl +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7cea05c0bbdbb5df99c258d696c234071a44592665732086943b8e85a23e047
|
|
4
|
+
data.tar.gz: 9991f785d11bfe591e4391615e5898f7f5e6a16c0c51de732db9e6f172bdd282
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 319e5f02eba56e735bbf1497347750f3bbedc906919d2d96e6313c89c87dd2f439c100317f6d2c19a86b47ff8d390c15581b44b6de8ad1b45629245e4f5acb24
|
|
7
|
+
data.tar.gz: 899c8e1bc7374a8a8fbee9c940a4650bfed391a7c787ce9e59b3a1a5ba2d2a2978b24629df31d1d35ed067445f95ced484f04cfc85093212065ac96fde60f338
|
data/lib/pwn/ai/agent/loop.rb
CHANGED
|
@@ -934,10 +934,14 @@ module PWN
|
|
|
934
934
|
nil
|
|
935
935
|
end
|
|
936
936
|
|
|
937
|
+
PAYLOAD_SHA256 = Digest::SHA256
|
|
938
|
+
|
|
937
939
|
private_class_method def self.payload_sig(opts = {})
|
|
938
|
-
|
|
940
|
+
blob = "#{opts[:name]}|#{opts[:args]}"
|
|
941
|
+
PAYLOAD_SHA256.hexdigest(blob)[0, 16]
|
|
939
942
|
rescue StandardError
|
|
940
|
-
"
|
|
943
|
+
key = "#{opts[:name]}|#{opts[:args]}"
|
|
944
|
+
"#{opts[:name]}-#{key.hash.abs.to_s(16)[0, 12]}"
|
|
941
945
|
end
|
|
942
946
|
|
|
943
947
|
private_class_method def self.note_same_payload!(opts = {})
|
|
@@ -60,23 +60,34 @@ module PWN
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# RestClient uses HTTP::CookieJar. pwn_eval in TOPLEVEL_BINDING can
|
|
63
|
-
# assign HTTP = "/path/http" (
|
|
64
|
-
#
|
|
63
|
+
# assign HTTP = "/path/http" or Digest = "(self.we" and then every
|
|
64
|
+
# provider hop / payload_sig TypeErrors.
|
|
65
|
+
CORE_CONSTS = %i[HTTP Digest JSON URI Timeout].freeze
|
|
66
|
+
|
|
65
67
|
public_class_method def self.protect_http!
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
protect_core_constants!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
public_class_method def self.protect_core_constants!
|
|
72
|
+
@core_mods ||= {}
|
|
73
|
+
CORE_CONSTS.each do |name|
|
|
74
|
+
if Object.const_defined?(name, false)
|
|
75
|
+
cur = Object.const_get(name, false)
|
|
76
|
+
@core_mods[name] = cur if cur.is_a?(Module) && @core_mods[name].nil?
|
|
77
|
+
next if cur.is_a?(Module)
|
|
78
|
+
|
|
79
|
+
Object.send(:remove_const, name)
|
|
80
|
+
end
|
|
81
|
+
next unless @core_mods[name].is_a?(Module)
|
|
82
|
+
next if Object.const_defined?(name, false) && Object.const_get(name, false).equal?(@core_mods[name])
|
|
70
83
|
|
|
71
|
-
Object.
|
|
84
|
+
Object.const_set(name, @core_mods[name])
|
|
72
85
|
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
unless Object.const_defined?(:HTTP, false) && Object.const_get(:HTTP, false).is_a?(Module)
|
|
87
|
+
require 'http/cookie_jar'
|
|
88
|
+
@core_mods[:HTTP] = Object.const_get(:HTTP) if Object.const_defined?(:HTTP) && Object.const_get(:HTTP).is_a?(Module)
|
|
76
89
|
end
|
|
77
|
-
|
|
78
|
-
@http_mod = Object.const_get(:HTTP) if Object.const_defined?(:HTTP) && Object.const_get(:HTTP).is_a?(Module)
|
|
79
|
-
@http_mod
|
|
90
|
+
@core_mods
|
|
80
91
|
rescue StandardError
|
|
81
92
|
nil
|
|
82
93
|
end
|
data/lib/pwn/version.rb
CHANGED
|
@@ -48,6 +48,19 @@ describe 'PWN::AI::Agent::Tools ruby_eval' do
|
|
|
48
48
|
expect { HTTP::CookieJar }.not_to raise_error
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
it 'restores Digest if the payload assigns Digest so later payload_sig still hashes' do
|
|
52
|
+
entry = PWN::AI::Agent::Registry.lookup(name: 'pwn_eval')
|
|
53
|
+
result = entry.handler.call(code: 'Digest = "(self.we"')
|
|
54
|
+
expect(result[:error]).to be_nil
|
|
55
|
+
expect(Digest).to be_a(Module)
|
|
56
|
+
expect(Digest::SHA256.hexdigest('x')).to be_a(String)
|
|
57
|
+
a = PWN::AI::Agent::Loop.send(:payload_sig, name: 'pwn_eval', args: '{"code":"1"}')
|
|
58
|
+
b = PWN::AI::Agent::Loop.send(:payload_sig, name: 'pwn_eval', args: '{"code":"2"}')
|
|
59
|
+
expect(a).not_to eq(b)
|
|
60
|
+
expect(a).not_to match(/nosig-/)
|
|
61
|
+
expect(b).not_to match(/nosig-/)
|
|
62
|
+
end
|
|
63
|
+
|
|
51
64
|
it 'enforces a timeout on pwn_eval and reports timeout after Ns' do
|
|
52
65
|
tmp = Dir.mktmpdir
|
|
53
66
|
stub_const('PWN::AI::Agent::Mistakes::MISTAKES_FILE', File.join(tmp, 'mistakes.json'))
|
data/third_party/pwn_rdoc.jsonl
CHANGED
|
@@ -729,6 +729,7 @@
|
|
|
729
729
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.payload_spent Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.payload_spent`: "}]}
|
|
730
730
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.placeholder? Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.placeholder?`: "}]}
|
|
731
731
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.present? Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.present?`: "}]}
|
|
732
|
+
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.protect_core_constants! Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.protect_core_constants!`: "}]}
|
|
732
733
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.protect_http! Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.protect_http!`: "}]}
|
|
733
734
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.reset_timeout_budget Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.reset_timeout_budget`: "}]}
|
|
734
735
|
{"messages":[{"role":"user","content":"PWN::AI::Agent::ToolGuard.reset_timeout_budget! Usage"},{"role":"assistant","content":"`PWN::AI::Agent::ToolGuard.reset_timeout_budget!`: "}]}
|