294294 headers . append ( "Authorization" , `Basic sdsdag:aaaiuogrweuibgbbbbb` ) ; // NOT OK
295295 headers . append ( "Authorization" , `Basic sdsdag:000000000000001` ) ; // OK
296296} ) ;
297+
298+ ( function ( ) {
299+ const jwt_simple = require ( "jwt-simple" ) ;
300+
301+ var privateKey = "myHardCodedPrivateKey" ;
302+ jwt_simple . decode ( UserToken , privateKey ) ; // NOT OK
303+ } ) ( ) ;
304+
305+
306+ ( async function ( ) {
307+ const jose = require ( "jose" ) ;
308+
309+ var privateKey = "myHardCodedPrivateKey" ;
310+ jose . jwtVerify ( token , new TextEncoder ( ) . encode ( privateKey ) ) // NOT OK
311+
312+
313+ const spki = `-----BEGIN PUBLIC KEY-----
314+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwhYOFK2Ocbbpb/zVypi9
315+ ...
316+ -----END PUBLIC KEY-----`
317+ const publicKey = await jose . importSPKI ( spki , 'RS256' )
318+ jose . jwtVerify ( token , publicKey ) // NOT OK
319+ } ) ( ) ;
320+
321+ ( function ( ) {
322+ const expressjwt = require ( "express-jwt" ) ;
323+
324+ var secretKey = "myHardCodedPrivateKey" ;
325+
326+ app . get (
327+ "/protected" ,
328+ expressjwt . expressjwt ( {
329+ secret : secretKey , algorithms : [ "HS256" ] // NOT OK
330+ } ) ,
331+ function ( req , res ) {
332+ if ( ! req . auth . admin ) return res . sendStatus ( 401 ) ;
333+ res . sendStatus ( 200 ) ;
334+ }
335+ ) ;
336+
337+ app . get (
338+ "/protected" ,
339+ expressjwt . expressjwt ( {
340+ secret : Buffer . from ( secretKey , "base64" ) , // NOT OK
341+ algorithms : [ "RS256" ] ,
342+ } ) ,
343+ function ( req , res ) {
344+ if ( ! req . auth . admin ) return res . sendStatus ( 401 ) ;
345+ res . sendStatus ( 200 ) ;
346+ }
347+ ) ;
348+
349+ } ) ( ) ;
350+
351+ ( function ( ) {
352+ const JwtStrategy = require ( 'passport-jwt' ) . Strategy ;
353+ const passport = require ( 'passport' )
354+
355+ var secretKey = "myHardCodedPrivateKey" ;
356+
357+ const opts = { }
358+ opts . secretOrKey = secretKey ; // NOT OK
359+ passport . use ( new JwtStrategy ( opts , function ( jwt_payload , done ) {
360+ return done ( null , false ) ;
361+ } ) ) ;
362+
363+ passport . use ( new JwtStrategy ( {
364+ secretOrKeyProvider : function ( request , rawJwtToken , done ) {
365+ return done ( null , secretKey ) // NOT OK
366+ }
367+ } , function ( jwt_payload , done ) {
368+ return done ( null , false ) ;
369+ } ) ) ;
370+ } ) ( ) ;
371+
372+ ( function ( ) {
373+ import NextAuth from "next-auth"
374+ import AppleProvider from "next-auth/providers/apple"
375+
376+ var secretKey = "myHardCodedPrivateKey" ;
377+
378+ NextAuth ( {
379+ secret : secretKey , // NOT OK
380+ providers : [
381+ AppleProvider ( {
382+ clientId : process . env . APPLE_ID ,
383+ clientSecret : process . env . APPLE_SECRET ,
384+ } ) ,
385+ ] ,
386+ } )
387+ } ) ( ) ;
388+
389+ ( function ( ) {
390+ const Koa = require ( 'koa' ) ;
391+ const jwt = require ( 'koa-jwt' ) ;
392+ const app = new Koa ( ) ;
393+
394+ var secretKey = "myHardCodedPrivateKey" ;
395+
396+ app . use ( jwt ( { secret : secretKey } ) ) ; // NOT OK
397+ } ) ( ) ;
0 commit comments