@@ -192,6 +192,24 @@ describe('Authentication API (OIDC)', () => {
192192 } )
193193 } )
194194
195+ // How Mallory might set their cookie:
196+ describe ( 'with malicious cookie but without origin' , ( ) => {
197+ let response
198+ before ( done => {
199+ var malcookie = cookie . replace ( / c o n n e c t \. s i d = ( \S + ) / , 'connect.sid=l33th4x0rzp0wn4g3;' )
200+ alice . get ( '/' )
201+ . set ( 'Cookie' , malcookie )
202+ . end ( ( err , res ) => {
203+ response = res
204+ done ( err )
205+ } )
206+ } )
207+
208+ it ( 'should return a 403' , ( ) => {
209+ expect ( response ) . to . have . property ( 'status' , 403 )
210+ } )
211+ } )
212+
195213 // Our origin isn't trusted by default
196214 describe ( 'with that cookie and our origin' , ( ) => {
197215 let response
@@ -228,7 +246,7 @@ describe('Authentication API (OIDC)', () => {
228246 } )
229247
230248 // Configuration for originsAllowed
231- describe ( 'without that cookie but with globally configured origin' , ( ) => {
249+ describe ( 'with that cookie but with globally configured origin' , ( ) => {
232250 let response
233251 before ( done => {
234252 alice . get ( '/' )
@@ -262,6 +280,25 @@ describe('Authentication API (OIDC)', () => {
262280 } )
263281 } )
264282
283+ // Configuration for originsAllowed with malicious cookie
284+ describe ( 'with malicious cookie but with globally configured origin' , ( ) => {
285+ let response
286+ before ( done => {
287+ var malcookie = cookie . replace ( / c o n n e c t \. s i d = ( \S + ) / , 'connect.sid=l33th4x0rzp0wn4g3;' )
288+ alice . get ( '/' )
289+ . set ( 'Cookie' , malcookie )
290+ . set ( 'Origin' , 'https://test.apps.solid.invalid' )
291+ . end ( ( err , res ) => {
292+ response = res
293+ done ( err )
294+ } )
295+ } )
296+
297+ it ( 'should return a 403' , ( ) => {
298+ expect ( response ) . to . have . property ( 'status' , 403 )
299+ } )
300+ } )
301+
265302 // Not authenticated but also wrong origin, TODO 401 or 403?
266303 describe ( 'without that cookie and a matching origin' , ( ) => {
267304 let response
@@ -296,6 +333,25 @@ describe('Authentication API (OIDC)', () => {
296333 expect ( response ) . to . have . property ( 'status' , 401 )
297334 } )
298335 } )
336+
337+ // Authenticated but origin not OK
338+ describe ( 'with malicious cookie and a non-matching origin' , ( ) => {
339+ let response
340+ before ( done => {
341+ var malcookie = cookie . replace ( / c o n n e c t \. s i d = ( \S + ) / , 'connect.sid=l33th4x0rzp0wn4g3;' )
342+ alice . get ( '/' )
343+ . set ( 'Cookie' , malcookie )
344+ . set ( 'Origin' , bobServerUri )
345+ . end ( ( err , res ) => {
346+ response = res
347+ done ( err )
348+ } )
349+ } )
350+
351+ it ( 'should return a 403' , ( ) => {
352+ expect ( response ) . to . have . property ( 'status' , 403 )
353+ } )
354+ } )
299355 } )
300356 } )
301357
0 commit comments