File tree Expand file tree Collapse file tree
test/src/test/java/jenkins/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ THE SOFTWARE.
179179 <dependency >
180180 <groupId >org.jenkins-ci.main</groupId >
181181 <artifactId >remoting</artifactId >
182- <version >2.53.3 </version >
182+ <version >2.53.4-20161112.024902-1 </version >
183183 </dependency >
184184
185185 <dependency >
Original file line number Diff line number Diff line change @@ -161,6 +161,15 @@ public void probeSpring2() throws Exception {
161161 probe (Payload .Spring2 , -1 );
162162 }
163163
164+ @ PresetData (PresetData .DataSet .ANONYMOUS_READONLY )
165+ @ Test
166+ @ Issue ("SECURITY-360" )
167+ public void ldap () throws Exception {
168+ // with a proper fix, this should fail with EXIT_CODE_REJECTED
169+ // otherwise this will fail with -1 exit code
170+ probe (Payload .Ldap , PayloadCaller .EXIT_CODE_REJECTED );
171+ }
172+
164173 private void probe (Payload payload , int expectedResultCode ) throws Exception {
165174 File file = File .createTempFile ("security-218" , payload + "-payload" );
166175 File moved = new File (file .getAbsolutePath () + "-moved" );
Original file line number Diff line number Diff line change 2424package jenkins .security .security218 ;
2525
2626import jenkins .security .security218 .ysoserial .payloads .*;
27- import net .sf .json .JSON ;
2827
2928
3029/**
@@ -46,8 +45,10 @@ public enum Payload {
4645 JRMPListener (JRMPListener .class ),
4746 JSON1 (JSON1 .class ),
4847 Spring1 (Spring1 .class ),
49- Spring2 (Spring2 .class );
50-
48+ Spring2 (Spring2 .class ),
49+ Ldap (Ldap .class ),
50+ ;
51+
5152 private final Class <? extends ObjectPayload > payloadClass ;
5253
5354 private Payload (Class <? extends ObjectPayload > payloadClass ) {
Original file line number Diff line number Diff line change 1+ package jenkins .security .security218 .ysoserial .payloads ;
2+
3+ import jenkins .security .security218 .ysoserial .util .PayloadRunner ;
4+
5+ import java .lang .reflect .Constructor ;
6+
7+ /**
8+ * @author Kohsuke Kawaguchi
9+ */
10+ public class Ldap extends PayloadRunner implements ObjectPayload <Object > {
11+
12+ public Object getObject (final String command ) throws Exception {
13+ // this is not a fully exploit, so we cannot honor the command,
14+ // but we want to check that we are blocking LdapAttribute
15+ Class <?> c = Class .forName ("com.sun.jndi.ldap.LdapAttribute" );
16+ Constructor <?> ctr = c .getDeclaredConstructor (String .class );
17+ ctr .setAccessible (true );
18+ return ctr .newInstance ("foo" );
19+ }
20+
21+ public static void main (final String [] args ) throws Exception {
22+ PayloadRunner .run (Ldap .class , args );
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments