[19019] 2016-07-19_[漏洞预警]CGI接口漏洞PHP,Go,Python等均受影响

文档创建者:s7ckTeam
浏览次数:7
最后更新:2025-01-18
2016-07-19_[漏洞预警]CGI接口漏洞PHP,Go,Python等均受影响 C G I P H P , G o , P y t h o n i n n 0 t e a m   2 0 1 6 - 0 7 - 1 9 h t t p o x y   i s   a   s e t   o f   v u l n e r a b i l i t i e s   t h a t   a f f e c t   a p p l i c a t i o n   c o d e   r u n n i n g   i n   C G I ,   o r   C G I - l i k e   e n v i r o n m e n t s .   I t c o m e s   d o w n   t o   a   s i m p l e   n a m e s p a c e   c o n f l i c t : R F C   3 8 7 5   ( C G I )   p u t s   t h e   H T T P     h e a d e r   f r o m   a   r e q u e s t   i n t o   t h e   e n v i r o n m e n t   v a r i a b l e s   a s     i s   a   p o p u l a r   e n v i r o n m e n t   v a r i a b l e   u s e d   t o   c o n f i g u r e   a n   o u t g o i n g   p r o x y T h i s   l e a d s   t o   a   r e m o t e l y   e x p l o i t a b l e   v u l n e r a b i l i t y .   I f   y o u r e   r u n n i n g   P H P   o r   C G I ,   y o u   s h o u l d   b l o c k   t h e     h e a d e r   n o w .   H e r e s   h o w . h t t p o x y   i s   a   v u l n e r a b i l i t y   f o r   s e r v e r - s i d e   w e b   a p p l i c a t i o n s .   I f   y o u r e   n o t   d e p l o y i n g   c o d e ,   y o u   d o n t   n e e d   t o   w o r r y . W h a t   c a n   h a p p e n   i f   m y   w e b   a p p l i c a t i o n   i s   v u l n e r a b l e ? I f   a   v u l n e r a b l e   H T T P   c l i e n t   m a k e s   a n   o u t g o i n g   H T T P   c o n n e c t i o n ,   w h i l e   r u n n i n g   i n   a   s e r v e r - s i d e   C G I   a p p l i c a t i o n ,   a n   a t t a c k e r   m a y   b e   a b l e   t o : P r o x y   t h e   o u t g o i n g   H T T P   r e q u e s t s   m a d e   b y   t h e   w e b   a p p l i c a t i o n D i r e c t   t h e   s e r v e r   t o   o p e n   o u t g o i n g   c o n n e c t i o n s   t o   a n   a d d r e s s   a n d   p o r t   o f   t h e i r   c h o o s i n g T i e   u p   s e r v e r   r e s o u r c e s   b y   f o r c i n g   t h e   v u l n e r a b l e   s o f t w a r e   t o   u s e   a   m a l i c i o u s   p r o x y h t t p o x y   i s   e x t r e m e l y   e a s y   t o   e x p l o i t   i n   b a s i c   f o r m .   A n d   w e   e x p e c t   s e c u r i t y   r e s e a r c h e r s   t o   b e   a b l e   t o   s c a n   f o r   i t   q u i c k l y .   L u c k i l y ,   i f   y o u   r e a d   o n a n d   f i n d   y o u   a r e   a f f e c t e d ,   e a s y   m i t i g a t i o n s   a r e   a v a i l a b l e . W h a t   I s   A f f e c t e d A   f e w   t h i n g s   a r e   n e c e s s a r y   t o   b e   v u l n e r a b l e : C o d e   r u n n i n g   u n d e r   a   C G I - l i k e   c o n t e x t ,   w h e r e     b e c o m e s   a   r e a l   o r   e m u l a t e d   e n v i r o n m e n t   v a r i a b l e A n   H T T P   c l i e n t   t h a t   t r u s t s   ,   a n d   c o n f i g u r e s   i t   a s   t h e   p r o x y T h a t   c l i e n t ,   u s e d   w i t h i n   a   r e q u e s t   h a n d l e r ,   m a k i n g   a n   H T T P   ( a s   o p p o s e d   t o   H T T P S )   r e q u e s t F o r   e x a m p l e ,   t h e   c o n f i r m e d   c a s e s   w e v e   f o u n d   s o   f a r : L a n g u a g e E n v i r o n m e n t H T T P   c l i e n t P H P p h p - f p m   m o d _ p h p G u z z l e   4 +   A r t a x P r o x y H T T P _ P R O X Y H T T P _ P R O X Y P r o x y H T T P _ P R O X Y H T T P _ P R O X Y
P y t h o n w s g i r e f . h a n d l e r s . C G I H a n d l e r   t w i s t e d . w e b . t w c g i . C G I S c r i p t r e q u e s t s G o n e t / h t t p / c g i n e t / h t t p L a n g u a g e E n v i r o n m e n t H T T P   c l i e n t B u t   o b v i o u s l y   t h e r e   m a y   b e   l a n g u a g e s   w e   h a v e n t   c o n s i d e r e d   y e t .   C G I   i s   a   c o m m o n   s t a n d a r d ,   a n d   s e e m s   t o   b e   b e c o m i n g   m o r e   p o p u l a r   o v e r   t i m e .   T a k e   t h e   b e l o w   a s   a   s a m p l e   o f   t h e   m o s t   c o m m o n l y   a f f e c t e d   s c e n a r i o s : P H P W h e t h e r   y o u   a r e   v u l n e r a b l e   d e p e n d s   o n   y o u r   s p e c i f i c   a p p l i c a t i o n   c o d e   a n d   P H P   l i b r a r i e s ,   b u t   t h e   p r o b l e m   s e e m s   f a i r l y   w i d e s p r e a d J u s t   u s i n g   o n e   o f   t h e   v u l n e r a b l e   l i b r a r i e s ,   w h i l e   p r o c e s s i n g   a   u s e r s   r e q u e s t ,   i s   e x p l o i t a b l e . I f   y o u r e   u s i n g   a   v u l n e r a b l e   l i b r a r y ,   t h i s   v u l n e r a b i l i t y   w i l l   a f f e c t   a n y   v e r s i o n   o f   P H P I t   e v e n   a f f e c t s   a l t e r n a t i v e   P H P   r u n t i m e s   s u c h   a s   H H V M   d e p l o y e d   u n d e r   F a s t C G I I t   i s   p r e s e n t   i n   G u z z l e ,   A r t a x ,   a n d   p r o b a b l y   m a n y ,   m a n y   l i b r a r i e s G u z z l e   v e r s i o n s   a f t e r   4 . 0 . 0 r c 2   a r e   v u l n e r a b l e ,   G u z z l e   3   a n d   b e l o w   i s   n o t . A n o t h e r   e x a m p l e   i s   i n   C o m p o s e r s   S t r e a m C o n t e x t B u i l d e r   u t i l i t y   c l a s s S o ,   f o r   e x a m p l e ,   i f   y o u   a r e   u s i n g   a   D r u p a l   m o d u l e   t h a t   u s e s   G u z z l e   6   a n d   m a k e s   a n   o u t g o i n g   H T T P   r e q u e s t   ( f o r   e x a m p l e ,   t o   c h e c k   a   w e a t h e r A P I ) ,   y o u   a r e   v u l n e r a b l e   t o   t h e   r e q u e s t   t h a t   p l u g i n   m a k e s   b e i n g   h t t p o x i e d . P y t h o n P y t h o n   c o d e   m u s t   b e   d e p l o y e d   u n d e r   C G I   t o   b e   v u l n e r a b l e .   U s u a l l y ,   t h a t l l   m e a n   t h e   v u l n e r a b l e   c o d e   w i l l   u s e   a   C G I   h a n d l e r   l i k e   T h i s   i s   n o t   c o n s i d e r e d   a   n o r m a l   w a y   o f   d e p l o y i n g   P y t h o n   w e b a p p s   ( m o s t   p e o p l e   a r e   u s i n g   W S G I   o r   F a s t C G I ,   b o t h   o f   w h i c h   a r e   n o t   a f f e c t e d ) , s o   v u l n e r a b l e   P y t h o n   a p p l i c a t i o n s   w i l l   p r o b a b l y   b e   m u c h   r a r e r   t h a n   v u l n e r a b l e   P H P   a p p l i c a t i o n s . w s g i ,   f o r   e x a m p l e ,   i s   n o t   v u l n e r a b l e ,   b e c a u s e   o s . e n v i r o n   i s   n o t   p o l l u t e d   b y   C G I   d a t a V u l n e r a b l e   v e r s i o n s   o f   t h e   r e q u e s t s   l i b r a r y   w i l l   t r u s t   a n d   u s e   ,   w i t h o u t   c h e c k i n g   i f   C G I   i s   i n   u s e G o G o   c o d e   m u s t   b e   d e p l o y e d   u n d e r   C G I   t o   b e   v u l n e r a b l e .   U s u a l l y ,   t h a t l l   m e a n   t h e   v u l n e r a b l e   c o d e   u s e s   t h e     p a c k a g e . A s   w i t h   P y t h o n ,   t h i s   i s   n o t   c o n s i d e r e d   a   u s u a l   w a y   o f   d e p l o y i n g   G o   a s   a   w e b   a p p l i c a t i o n ,   s o   t h i s   v u l n e r a b i l i t y   s h o u l d   b e   r e l a t i v e l y   r a r e G o s     p a c k a g e ,   b y   c o m p a r i s o n ,   d o e s   n o t   s e t   a c t u a l   e n v i r o n m e n t   v a r i a b l e s ,   s o   i t   i s   n o t   v u l n e r a b l e V u l n e r a b l e   v e r s i o n s   o f     w i l l   t r u s t   a n d   u s e     f o r   o u t g o i n g   r e q u e s t s ,   w i t h o u t   c h e c k i n g   i f   C G I   i s   i n   u s e I m m e d i a t e   M i t i g a t i o n T h e   b e s t   i m m e d i a t e   m i t i g a t i o n   i s   t o   b l o c k   H T T P _ P R O X Y w s g i r e f . h a n d l e r s . C G I H a n d l e r o s . e n v i r o n [ ' H T T P _ P R O X Y ' ] n e t / h t t p / c g i n e t / h t t p / f c g i n e t / h t t p H T T P _ P R O X Y
  r e q u e s t   h e a d e r s   a s   e a r l y   a s   p o s s i b l e ,   a n d   b e f o r e   t h e y   h i t   y o u r   a p p l i c a t i o n .   T h i s   i s   e a s y   a n d   s a f e . I t s   s a f e   b e c a u s e   t h e     h e a d e r   i s   u n d e f i n e d   b y   t h e   I E T F ,   a n d   i s n t   l i s t e d   o n   t h e   I A N A s   r e g i s t r y   o f   m e s s a g e   h e a d e r s .   T h i s   m e a n s   t h e r e   i s   n o   s t a n d a r d   u s e   f o r   t h e h e a d e r   a t   a l l ;   n o t   e v e n   a   p r o v i s i o n a l   u s e - c a s e . S t a n d a r d s - c o m p l i a n t   H T T P   c l i e n t s   a n d   s e r v e r s   w i l l   n e v e r   r e a d   o r   s e n d   t h i s   h e a d e r . Y o u   c a n   e i t h e r   s t r i p   t h e   h e a d e r   o r   c o m p l e t e l y   b l o c k   r e q u e s t s   a t t e m p t i n g   t o   u s e   i t . Y o u   s h o u l d   t r y   t o   d o   y o u r   m i t i g a t i o n   a s   e a r l y   a n d   a s   f a r   u p s t r e a m   a s   y o u   c a n . D o   i t   a t   t h e   e d g e ,   w h e r e   H T T P   r e q u e s t s   f i r s t   e n t e r   y o u r   s y s t e m . T h a t   w a y ,   y o u   c a n   f i x   l o t s   o f   v u l n e r a b l e   s o f t w a r e   a t   o n c e . E v e r y t h i n g   b e h i n d   a   r e v e r s e   p r o x y   o r   a p p l i c a t i o n   f i r e w a l l   t h a t   s t r i p s   t h e     h e a d e r   i s   s a f e ! H o w   y o u   b l o c k   a     h e a d e r   d e p e n d s   o n   t h e   s p e c i f i c s   o f   y o u r   s e t u p .   T h e   e a r l i e s t   c o n v e n i e n t   p l a c e   t o   b l o c k   t h e   h e a d e r   m i g h t   b e   a t   a   w e b   a p p l i c a t i o n   f i r e w a l l   d e v i c e , o r   d i r e c t l y   o n   t h e   w e b s e r v e r   r u n n i n g   A p a c h e   o r   N g i n x .   H e r e   a r e   a   f e w   o f   t h e   m o r e   c o m m o n   m i t i g a t i o n s : N g i n x / F a s t C G I U s e   t h i s   t o   b l o c k   t h e   h e a d e r   f r o m   b e i n g   p a s s e d   o n   t o   P H P - F P M ,   P H P - P M   e t c . I n   F a s t C G I   c o n f i g u r a t i o n s ,   P H P   i s   v u l n e r a b l e   ( b u t   m a n y   o t h e r   l a n g u a g e s   t h a t   u s e   N g i n x   F a s t C G I   a r e   n o t ) . A p a c h e F o r   s p e c i f i c   A p a c h e   c o v e r a g e   ( a n d   d e t a i l s   f o r   o t h e r   A p a c h e   s o f t w a r e   p r o j e c t s   l i k e   T o m c a t ) ,   w e   s t r o n g l y   r e c o m m e n d   y o u   r e a d   t h e   A p a c h e S o f t w a r e   F o u n d a t i o n s   o f f i c i a l   a d v i s o r y   o n   t h e   m a t t e r .   T h e   v e r y   b a s i c   m i t i g a t i o n   i n f o r m a t i o n   y o u l l   f i n d   b e l o w   i s   c o v e r e d   i n   m u c h   g r e a t e r   d e p t h t h e r e . I f   y o u r e   u s i n g   A p a c h e   H T T P   S e r v e r   w i t h   ,   l a n g u a g e s   l i k e   G o   a n d   P y t h o n   m a y   b e   v u l n e r a b l e   ( t h e     e n v   v a r   i s   r e a l ) .   A n d     i s   a f f e c t e d   d u e   t o   t h e   n a t u r e   o f   P H P .   I f   y o u   a r e   u s i n g   m o d _ h e a d e r s ,   y o u   c a n   u n s e t   t h e     h e a d e r   b e f o r e   f u r t h e r   p r o c e s s i n g   w i t h   t h i s   d i r e c t i v e : I f   y o u   a r e   u s i n g   m o d _ s e c u r i t y ,   y o u   c a n   u s e   a     t o   d e n y   t r a f f i c   w i t h   a     h e a d e r .   H e r e s   a n   e x a m p l e ,   v a r y   t h e   a c t i o n   t o   t a s t e ,   a n d   m a k e   s u r e     i s   o n .   T h e   1 0 0 0 0 0 5   I D   h a s   b e e n   a s s i g n e d   t o   t h i s   i s s u e . F i n a l l y ,   i f   y o u r e   u s i n g   A p a c h e   T r a f f i c   S e r v e r ,   i t s   n o t   a f f e c t e d ,   b u t   y o u   c a n   u s e   i t   t o   s t r i p   t h e   P r o x y   h e a d e r ;   v e r y   h e l p f u l   f o r   a n y   s e r v i c e s   s i t t i n g b e h i n d   i t .   A g a i n ,   s e e   t h e   A S F s   g u i d a n c e . P r o x y P r o x y P r o x y P r o x y f a s t c g i _ p a r a m   H T T P _ P R O X Y   " " ; m o d _ c g i H T T P _ P R O X Y m o d _ p h p P r o x y R e q u e s t H e a d e r   u n s e t   P r o x y   e a r l y S e c R u l e P r o x y S e c R u l e E n g i n e S e c R u l e   & R E Q U E S T _ H E A D E R S : P r o x y   " @ g t   0 "   " i d : 1 0 0 0 0 0 5 , l o g , d e n y , m s g : ' h t t p o x y   d e n i e d ' "
H A P r o x y T h i s   w i l l   s t r i p   t h e   h e a d e r   o f f   r e q u e s t s : V a r n i s h F o r   V a r n i s h ,   t h e   f o l l o w i n g   s h o u l d   u n s e t   t h e   h e a d e r .   A d d   i t   t o   t h e   p r e - e x i s t i n g   v c l _ r e c v   s e c t i o n : M i c r o s o f t   I I S   w i t h   P H P   o r   a   C G I   f r a m e w o r k h t t p o x y   d o e s   n o t   a f f e c t   a n y   M i c r o s o f t   W e b   F r a m e w o r k s ,   e . g .   n o t   A S P . N E T   n o r   A c t i v e   S e r v e r   P a g e s .   B u t   i f   y o u   h a v e   i n s t a l l e d   P H P   o r   a n y o t h e r   t h i r d   p a r t y   f r a m e w o r k   o n   t o p   o f   I I S ,   w e   r e c o m m e n d   a p p l y i n g   m i t i g a t i o n   s t e p s   t o   p r o t e c t   f r o m   h t t p o x y   a t t a c k s . U p d a t e   y o u r     w i t h   t h e   f o l l o w i n g   r u l e : O t h e r   C G I   s o f t w a r e   a n d   a p p l i c a t i o n s P l e a s e   l e t   u s   k n o w   o f   o t h e r   p l a c e s   w h e r e   h t t p o x y   i s   f o u n d .   W e d   b e   h a p p y   t o   h e l p   y o u   c o m m u n i c a t e   f i x e s   f o r   y o u r   p l a t f o r m ,   s e r v e r   o r   l i b r a r y   i f y o u   a r e   a f f e c t e d .   C o n t a c t   c o n t a c t @ h t t p o x y . o r g   o r   @ h t t p o x y t o   l e t   u s   k n o w .   O r   m a k e   a   P R   a g a i n s t   t h e   h t t p o x y - o r g   r e p o . I n e f f e c t i v e   f i x e s   i n   P H P U s e r l a n d   P H P   f i x e s   d o n t   w o r k .   D o n t   b o t h e r : U s i n g     d o e s   n o t   a f f e c t   t h e   v a l u e   r e t u r n e d   f r o m   ,   s o   i s   n o t   a n   e f f e c t i v e   m i t i g a t i o n U s i n g     d o e s   n o t   w o r k   e i t h e r   ( t o   b e   p r e c i s e :   i t   o n l y   w o r k s   i f   t h a t   v a l u e   i s   c o m i n g   f r o m   a n   a c t u a l   e n v i r o n m e n t   v a r i a b l e   r a t h e r   t h a n   a   h e a d e r     s o ,   i t c a n n o t   b e   u s e d   f o r   m i t i g a t i o n ) h t t p - r e q u e s t   d e l - h e a d e r   P r o x y s u b   v c l _ r e c v   {         [ . . . ]         u n s e t   r e q . h t t p . p r o x y ;         [ . . . ] } a p p h o s t . c o n f i g < s y s t e m . w e b S e r v e r >         < r e w r i t e >                 < r u l e s >                         < r u l e   n a m e = " E r a s e   H T T P _ P R O X Y "   p a t t e r n S y n t a x = " W i l d c a r d " >                                 < m a t c h   u r l = " * . * "   / >                                 < s e r v e r V a r i a b l e s >                                         < s e t   n a m e = " H T T P _ P R O X Y "   v a l u e = " "   / >                                 < / s e r v e r V a r i a b l e s >                                 < a c t i o n   t y p e = " N o n e "   / >                         < / r u l e >                 < / r u l e s >         < / r e w r i t e > < / s y s t e m . w e b S e r v e r > u n s e t ( $ _ S E R V E R [ ' H T T P _ P R O X Y ' ] ) g e t e n v ( ) p u t e n v ( ' H T T P _ P R O X Y = ' )
P r e v e n t i o n S u m m a r y I f   y o u   c a n   a v o i d   i t ,   d o   n o t   d e p l o y   i n t o   e n v i r o n m e n t s   w h e r e   t h e   C G I   d a t a   i s   m e r g e d   i n t o   t h e   a c t u a l   e n v i r o n m e n t   v a r i a b l e s U s e   a n d   e x p e c t     t o   s e t   t h e   p r o x y   f o r   a   C G I   a p p l i c a t i o n s   i n t e r n a l   r e q u e s t s ,   i f   n e c e s s a r y Y o u   c a n   s t i l l   s u p p o r t   ,   b u t   y o u   m u s t   a s s e r t   t h a t   C G I   i s   n o t   i n   u s e I n   P H P ,   c h e c k   O t h e r w i s e ,   a   s i m p l e   c h e c k   i s   t o   n o t   t r u s t     i f     i s   a l s o   s e t .   R F C   3 8 7 5   s e e m s   t o   r e q u i r e   t h i s   m e t a - v a r i a b l e : T h e     m e t a - v a r i a b l e   M U S T   b e   s e t   t o   t h e   m e t h o d   w h i c h   s h o u l d   b e   u s e d   b y   t h e   s c r i p t   t o   p r o c e s s   t h e   r e q u e s t D o n t   T r u s t     U n d e r   C G I T o   p u t   i t   p l a i n l y :   t h e r e   i s   n o   w a y   t o   t r u s t   t h e   v a l u e   o f   a n     e n v   v a r   i n   a   C G I   e n v i r o n m e n t .   T h e y   c a n n o t   b e   d i s t i n g u i s h e d   f r o m   r e q u e s t   h e a d e r s   a c c o r d i n g   t o   t h e   s p e c i f i c a t i o n .   S o ,   a n y   u s a g e   o f   i n   a   C G I   c o n t e x t   i s   s u s p i c i o u s . I f   y o u   n e e d   t o   c o n f i g u r e   t h e   p r o x y   o f   a   C G I   a p p l i c a t i o n   v i a   a n   e n v i r o n m e n t   v a r i a b l e ,   u s e   a   v a r i a b l e   n a m e   t h a t   w i l l   n e v e r   c o n f l i c t   w i t h   r e q u e s t h e a d e r s .   T h a t   i s :   o n e   t h a t   d o e s   n o t   b e g i n   w i t h   .   W e   s t r o n g l y   r e c o m m e n d   y o u   g o   f o r   .   ( A s   s e e n   i n   R u b y   a n d   l i b w w w - p e r l s   m i t i g a t i o n s   f o r   t h i s   i s s u e . ) P H P C L I - o n l y   c o d e   m a y   s a f e l y   t r u s t     o r   .   B u t   b e a r   i n   m i n d   t h a t   c o d e   w r i t t e n   f o r   t h e   C L I   c o n t e x t   o f t e n   e n d s   u p   r u n n i n g   i n   a   S A P I   e v e n t u a l l y ,   p a r t i c u l a r l y   u t i l i t y   o r   l i b r a r y   c o d e .   A n d , w i t h   o p e n   s o u r c e   c o d e ,   t h a t   m i g h t   n o t   e v e n   b e   y o u r   d o i n g .   S o ,   i f   y o u   a r e   g o i n g   t o   r e l y   o n     a t   a l l ,   y o u   s h o u l d   g u a r d   t h a t   c o d e   w i t h   a   c h e c k   o f   t h e   c o n s t a n t . C G I _ H T T P _ P R O X Y H T T P _ P R O X Y P H P _ S A P I   = =   ' c l i ' H T T P _ P R O X Y R E Q U E S T _ M E T H O D R E Q U E S T _ M E T H O D H T T P _ P R O X Y H T T P _ H T T P _ P R O X Y H T T P _ C G I _ H T T P _ P R O X Y $ _ S E R V E R [ ' H T T P _ P R O X Y ' ] g e t e n v ( ' H T T P _ P R O X Y ' ) H T T P _ P R O X Y P H P _ S A P I
N e t w o r k   C o n f i g u r a t i o n   a s   P r e v e n t i o n A   d e f e n s e - i n - d e p t h   s t r a t e g y   t h a t   c a n   c o m b a t   h t t p o x y   ( a n d   e n t i r e   c l a s s e s   o f   o t h e r   s e c u r i t y   p r o b l e m s )   i s   t o   s e v e r e l y   r e s t r i c t   t h e   o u t g o i n g   r e q u e s t s y o u r   w e b   a p p l i c a t i o n   c a n   m a k e   t o   a n   a b s o l u t e   m i n i m u m .   F o r   e x a m p l e ,   i f   a   w e b   a p p l i c a t i o n   i s   f i r e w a l l e d   i n   s u c h   a   w a y   t h a t   i t   c a n n o t   m a k e o u t g o i n g   H T T P   r e q u e s t s ,   a n   a t t a c k e r   w i l l   n o t   b e   a b l e   t o   r e c e i v e   t h e   m i s p r o x i e d   r e q u e s t s   ( b e c a u s e   t h e   w e b   a p p l i c a t i o n   i s   p r e v e n t e d   f r o m c o n n e c t i n g   t o   t h e   a t t a c k e r ) . H T T P S A n d ,   o f   c o u r s e ,   a n o t h e r   d e f e n s e - i n - d e p t h   s t r a t e g y   t h a t   w o r k s   i s   t o   u s e   H T T P S   f o r   i n t e r n a l   r e q u e s t s ,   n o t   j u s t   f o r   s e c u r i n g   y o u r   s i t e s c o n n e c t i o n s   t o   t h e   o u t s i d e   w o r l d .   T h o s e   a r e n t   a f f e c t e d   b y . H o w   I t   W o r k s U s i n g   P H P   a s   a n   e x a m p l e ,   b e c a u s e   i t   i s   i l l u s t r a t i v e .   P H P   h a s   a   m e t h o d   c a l l e d   1 . T h e r e   i s   a   c o m m o n   v u l n e r a b i l i t y   i n   m a n y   P H P   l i b r a r i e s   a n d   a p p l i c a t i o n s ,   i n t r o d u c e d   b y   c o n f u s i n g   f o r   a   m e t h o d   t h a t   o n l y   r e t u r n s   e n v i r o n m e n t   v a r i a b l e s .   I n   f a c t ,   g e t e n v ( )   i s   c l o s e r   t o   t h e   s u p e r g l o b a l :   i t   c o n t a i n s   b o t h   e n v i r o n m e n t   v a r i a b l e s   a n d   u s e r - c o n t r o l l e d   d a t a . S p e c i f i c a l l y ,   w h e n   P H P   i s   r u n n i n g   u n d e r   a   C G I - l i k e   s e r v e r ,   t h e   H T T P   r e q u e s t   h e a d e r s   ( d a t a   s u p p l i e d   b y   t h e   c l i e n t )   a r e   m e r g e d   i n t o   t h e     s u p e r g l o b a l   u n d e r   k e y s   b e g i n n i n g   w i t h   .   T h i s   i s   t h e   s a m e   i n f o r m a t i o n   t h a t     r e a d s   f r o m . W h e n   a   u s e r   s e n d s   a   r e q u e s t   w i t h   a     h e a d e r ,   t h e   h e a d e r   a p p e a r s   t o   t h e   P H P   a p p l i c a t i o n   a s .   S o m e   c o m m o n   P H P   l i b r a r i e s   h a v e   b e e n   t r u s t i n g   t h i s   v a l u e ,   e v e n   w h e n   r u n   i n   a   C G I / S A P I   e n v i r o n m e n t . R e a d i n g   a n d   t r u s t i n g     i s   e x a c t l y   t h e   s a m e   v u l n e r a b i l i t y ,   b u t   t e n d s   t o   h a p p e n   m u c h   l e s s   o f t e n   ( p e r h a p s   b e c a u s e   o f   g e t e n v s   n a m e ,   p e r h a p s   b e c a u s e   t h e   s e m a n t i c s   o f t h e   s u p e r g l o b a l   a r e   b e t t e r   u n d e r s t o o d   a m o n g   t h e   c o m m u n i t y ) . M i n i m a l   e x a m p l e   c o d e N o t e   t h a t   t h e s e   e x a m p l e s   r e q u i r e   d e p l o y m e n t   i n t o   a   v u l n e r a b l e   e n v i r o n m e n t   b e f o r e   t h e r e   i s   a c t u a l l y   a   v u l n e r a b i l i t y   ( e . g .   p h p - f p m ,   o r   A p a c h e s   ) P H P H T T P _ P R O X Y g e t e n v ( ) g e t e n v $ _ S E R V E R $ _ S E R V E R H T T P _ g e t e n v P r o x y g e t e n v ( ' H T T P _ P R O X Y ' ) $ _ S E R V E R [ ' H T T P _ P R O X Y ' ] $ _ S E R V E R S c r i p t A l i a s
P y t h o n G o M o r e   c o m p l e t e   P o C   r e p o s   ( u s i n g   D o c k e r ,   a n d   t e s t i n g   w i t h   a n   a c t u a l   l i s t e n e r   f o r   t h e   p r o x i e d   r e q u e s t )   h a v e   b e e n   p r e p a r e d   u n d e r   t h e   h t t p o x y G i t h u b   o r g a n i z a t i o n . W h y   I t   H a p p e n e d U n d e r   t h e   C G I   s p e c ,   h e a d e r s   a r e   p r o v i d e d   m i x e d   i n t o   t h e   e n v i r o n m e n t   v a r i a b l e s .   ( T h e s e   a r e   f o r m a l l y   k n o w n   a s   P r o t o c o l - S p e c i f i c   M e t a - V a r i a b l e s 2 ) .   T h a t s   j u s t   t h e   w a y   t h e   s p e c   w o r k s ,   n o t   a   f a i l u r e   o r   b u g . T h e   g o a l   o f   t h e   c o d e ,   i n   m o s t   o f   t h e   v u l n e r a b i l i t i e s ,   i s   t o   f i n d   t h e   c o r r e c t   p r o x y   t o   u s e ,   w h e n   a u t o - c o n f i g u r i n g   a   c l i e n t   f o r   t h e   i n t e r n a l   H T T P r e q u e s t   m a d e   s h o r t l y   a f t e r .   T h i s   t a s k   i n   R u b y   c o u l d   b e   c o m p l e t e d   b y   t h e     m e t h o d   o f   ,   w h i c h   n o t e s :   a n d     a r e   t r e a t e d   s p e c i a l l y   u n d e r   t h e   C G I   e n v i r o n m e n t ,   b e c a u s e   m a y   b e   s e t   b y   P r o x y :   h e a d e r .   S o     i s   n o t   u s e d .     i s   n o t   u s e d   t o o   i f   t h e   v a r i a b l e   i s   c a s e   i n s e n s i t i v e .     c a n   b e   u s e d   i n s t e a d .   F r o m   t h e   R u b y   s t d l i b   d o c u m e n t a t i o n O t h e r   i n s t a n c e s   o f   t h e   s a m e   v u l n e r a b i l i t y   a r e   p r e s e n t   i n   o t h e r   l a n g u a g e s .   F o r   e x a m p l e ,   w h e n   u s i n g   G o s     m o d u l e ,   a n d   d e p l o y i n g   a s   a   C G I   a p p l i c a t i o n .   T h i s   i n d i c a t e s   t h e   v u l n e r a b i l i t y   i s   a   s t a n d a r d   d a n g e r   i n   C G I   e n v i r o n m e n t s . H i s t o r y   o f   h t t p o x y $ c l i e n t   =   n e w   G u z z l e H t t p C l i e n t ( ) ; $ c l i e n t - > g e t ( ' h t t p : / / a p i . i n t e r n a l / ? s e c r e t = f o o ' ) f r o m   w s g i r e f . h a n d l e r s   i m p o r t   C G I H a n d l e r d e f   a p p l i c a t i o n ( e n v i r o n ,   s t a r t _ r e s p o n s e ) :         r e q u e s t s . g e t ( " h t t p : / / a p i . i n t e r n a l / ? s e c r e t = f o o " ) C G I H a n d l e r ( ) . r u n ( a p p l i c a t i o n ) c g i . S e r v e (         h t t p . H a n d l e r F u n c ( f u n c ( w   h t t p . R e s p o n s e W r i t e r ,   r   * h t t p . R e q u e s t )   {                 r e s ,   _   : =   h t t p . G e t ( " h t t p : / / a p i . i n t e r n a l / ? s e c r e t = f o o " )                 / /   [ . . . ] f i n d _ p r o x y U R I : : G e n e r i c h t t p _ p r o x y H T T P _ P R O X Y H T T P _ P R O X Y H T T P _ P R O X Y h t t p _ p r o x y C G I _ H T T P _ P R O X Y n e t / h t t p / c g i
T h i s   b u g   w a s   f i r s t   d i s c o v e r e d   o v e r   1 5   y e a r s   a g o .   T h e   t i m e l i n e   g o e s   s o m e t h i n g   l i k e : M a r c h   2 0 0 1 T h e   i s s u e   i s   d i s c o v e r e d   i n   l i b w w w - p e r l   a n d   f i x e d .   R e p o r t e d   b y   R a n d a l   L .   S c h w a r t z .   3 A p r i l   2 0 0 1 T h e   i s s u e   i s   d i s c o v e r e d   i n   c u r l ,   a n d   f i x e d   t h e r e   t o o   ( a l b e i t   p r o b a b l y   n o t   f o r   W i n d o w s ) .   R e p o r t e d   b y   C r i s   B a i l i f f .   4 J u l y   2 0 1 2 I n   i m p l e m e n t i n g     f o r   ,   t h e   R u b y   t e a m   n o t i c e   a n d   a v o i d   t h e   p o t e n t i a l   i s s u e .   N i c e   w o r k   A k i r a   T a n a k a !   5 N o v e m b e r   2 0 1 3 T h e   i s s u e   i s   m e n t i o n e d   o n   t h e   n g i n x   m a i l i n g   l i s t .   T h e   u s e r   h u m b l y   p o i n t s   o u t   t h e   i s s u e :   u n l e s s   I m   m i s s i n g   s o m e t h i n g ,   w h i c h   i s   v e r y   p o s s i b l e . N o ,   J o n a t h a n   M a t t h e w s ,   y o u   w e r e   e x a c t l y   r i g h t !   6 F e b r u a r y   2 0 1 5 T h e   i s s u e   i s   m e n t i o n e d   o n   t h e   A p a c h e   h t t p d - d e v   m a i l i n g   l i s t .   S p o t t e d   b y   S t e f a n   F r i t s c h .   7 J u l y   2 0 1 6 S c o t t   G e a r y ,   a n   e n g i n e e r   a t   V e n d ,   f o u n d   a n   i n s t a n c e   o f   t h e   b u g   i n   t h e   w i l d .   T h e   V e n d   s e c u r i t y   t e a m   f o u n d   t h e   v u l n e r a b i l i t y   w a s   s t i l l   e x p l o i t a b l e i n   P H P ,   a n d   p r e s e n t   i n   m a n y   m o d e r n   l a n g u a g e s   a n d   l i b r a r i e s .   W e   s t a r t e d   t o   d i s c l o s e   t o   s e c u r i t y   r e s p o n s e   t e a m s . S o ,   t h e   b u g   w a s   l y i n g   d o r m a n t   f o r   y e a r s ,   l i k e   a   l a t e n t   i n f e c t i o n :   p o x .   W e   i m a g i n e   t h a t   m a n y   p e o p l e   m a y   h a v e   f o u n d   t h e   i s s u e   o v e r   t h e   y e a r s ,   b u t n e v e r   i n v e s t i g a t e d   i t s   s c o p e   i n   o t h e r   l a n g u a g e s   a n d   l i b r a r i e s .   I f   y o u v e   f o u n d   a   h i s t o r i c a l   d i s c u s s i o n   o f   i n t e r e s t   t h a t   w e v e   m i s s e d ,   l e t   u s   k n o w . C V E s h t t p o x y   h a s   a   n u m b e r   o f   C V E s   a s s i g n e d .   T h e s e   c o v e r   t h e   c a s e s   w h e r e a   l a n g u a g e   o r   C G I   i m p l e m e n t a t i o n   m a k e s   t h e     h e a d e r   a v a i l a b l e   i n   s u c h   a   w a y   t h a t   t h e   a p p l i c a t i o n   c a n n o t   t e l l   w h e t h e r   i t   i s   a   r e a l   e n v i r o n m e n t   v a r i a b l e ,   o r a n   a p p l i c a t i o n   t r u s t s   t h e   v a l u e   o f   t h e     e n v i r o n m e n t   v a r i a b l e   b y   d e f a u l t   i n   a   C G I   e n v i r o n m e n t   ( b u t   o n l y   w h e r e   t h a t   a p p l i c a t i o n   s h o u l d   h a v e   b e e n   a b l e   t o   t e l l   i t   c a m e   f r o m   a   r e q u e s t ) T h e   a s s i g n e d   C V E s   s o   f a r : C V E - 2 0 1 6 - 5 3 8 5 :   P H P C V E - 2 0 1 6 - 5 3 8 6 :   G o C V E - 2 0 1 6 - 5 3 8 7 :   A p a c h e   H T T P   S e r v e r C V E - 2 0 1 6 - 5 3 8 8 :   A p a c h e   T o m c a t C V E - 2 0 1 6 - 1 0 0 0 1 0 9 :   H H V M C V E - 2 0 1 6 - 1 0 0 0 1 1 0 :   P y t h o n W e   s u s p e c t   t h e r e   m a y   b e   m o r e   C V E s   c o m i n g   f o r   h t t p o x y ,   a s   l e s s   c o m m o n   s o f t w a r e   i s   c h e c k e d   o v e r .   I f   y o u   w a n t   t o   g e t   a   C V E   a s s i g n e d   f o r a n   h t t p o x y   i s s u e ,   t h e r e   a r e   a   c o u p l e   o f   o p t i o n s : F o r   o p e n   s o u r c e   c o d e   p r o j e c t s ,   y o u   c a n   u s e   t h e   D i s t r i b u t e d   W e a k n e s s   F i l i n g   P r o j e c t   ( D W F ) .   T h e y   h a v e   a   s i m p l e   w a y   t o   r e p o r t   ( p u b l i c )   i s s u e s u s i n g   t h e   f o r m   a t   i w a n t a c v e . o r g F o r   c l o s e d   s o u r c e   c o d e   p r o j e c t s ,   y o u   c a n   t a l k   t o   M I T R E ,   o r   o n e   o f   t h e i r   p a r t i c i p a t i n g   C N A s / v e n d o r s / c o o r d i n a t o r s . H T T P _ P R O X Y N e t : : H T T P P r o x y H T T P _ P R O X Y
T h a n k s   a n d   F u r t h e r   C o v e r a g e W e l l   b e   l i n k i n g   t o   o f f i c i a l   a n n o u n c e m e n t s   f r o m   a f f e c t e d   t e a m s   h e r e ,   a s   t h e y   b e c o m e   a v a i l a b l e . T h e   C E R T   v u l n e r a b i l i t y   n o t e   -   V U # 7 9 7 8 9 6 T h e   A p a c h e   S o f t w a r e   F o u n d a t i o n   a d v i s o r y D r u p a l   a d v i s o r y C l o u d f l a r e   s i t e s   p r o t e c t e d   f r o m   h t t p o x y O v e r   t h e   p a s t   t w o   w e e k s ,   t h e   V e n d   s e c u r i t y   t e a m   w o r k e d   t o   d i s c l o s e   t h e   i s s u e   r e s p o n s i b l y   t o   a s   m a n y   a f f e c t e d   p a r t i e s   a s   w e   c o u l d .   W e d   l i k e t o   t h a n k   t h e   m e m b e r s   o f : T h e   R e d   H a t   P r o d u c t   S e c u r i t y   t e a m ,   w h o   p r o v i d e d   e x t r e m e l y   u s e f u l   a d v i c e   a n d   a c c e s s   t o   t h e i r   e x p e r i e n c e   d i s c l o s i n g   w i d e s p r e a d   v u l n e r a b i l i t i e s -   i f   y o u r e   s i t t i n g   o n   a   b i g   o r   c o m p l i c a t e d   d i s c l o s u r e ,   t h e y r e   a   g r e a t   r e s o u r c e   t o   r e a c h   o u t   t o   f o r   h e l p . T h e   l a n g u a g e   a n d   i m p l e m e n t a t i o n   t e a m s ,   w h o   k e p t   t o   d i s c l o s u r e   n o r m s   a n d   p r o v i d e d   l i v e l y   d i s c u s s i o n . T h e r e s   a n   e x t r a   p a g e   w i t h   s o m e   m e t a - d i s c u s s i o n   o n   t h e   w h o l e   n a m e d   d i s c l o s u r e   t h i n g   a n d   c o n t a c t   d e t a i l s .   T h e   c o n t e n t   o n   t h i s   p a g e   i s   l i c e n s e d a s   C C 0   ( T L ; D R :   u s e   w h a t   y o u   l i k e ,   n o   p e r m i s s i o n / a t t r i b u t i o n   n e c e s s a r y ) . I v e   p u t   t o g e t h e r   s o m e   m o r e   o p i n i o n a t e d   n o t e s   o n   h t t p o x y   o n   m y   M e d i u m   a c c o u n t . R e g a r d s , D o m i n i c   S c h e i r l i n c k   a n d   t h e   h t t p o x y   d i s c l o s u r e   t e a m P a g e   u p d a t e d   a t   2 0 1 6 - 0 7 - 1 8   1 5 : 1 5   U T C R e f e r e n c e s 1 .   T h e   P H P   d o c u m e n t a t i o n   m a n u a l   p a g e   f o r   g e t e n v   2 .   R F C   3 8 7 5   4 . 1 . 1 8 :   P r o t o c o l - S p e c i f i c   M e t a - V a r i a b l e s   3 .   T h e   f i x   a p p l i e d   c o r r e c t l y   h a n d l e s   c a s e s   w i t h   c a s e - i n s e n s i t i v e   e n v i r o n m e n t   v a r i a b l e s .   l i b w w w - p e r l - 5 . 5 1   a n n o u n c e m e n t   4 .   T h e   f i x   a p p l i e d   t o   C u r l   d o e s   n o t   c o r r e c t l y   h a n d l e   c a s e s   w i t h   c a s e - i n s e n s i t i v e   e n v i r o n m e n t   v a r i a b l e s   -   i t   s p e c i f i c a l l y   m e n t i o n s   t h e   f i x   w o u l d   n o t b e   e n o u g h   f o r   N T   ( W i n d o w s ) .   T h e   c o m m i t   i t s e l f   c a r r i e s   t h e   p r e s c i e n t   m e s s a g e   s i n c e   i t   m i g h t   b e c o m e   a   s e c u r i t y   p r o b l e m .   5 .   T h e   m i t i g a t i o n   i n   R u b y ,   l i k e   t h a t   f o r   l i b w w w - p e r l ,   c o r r e c t l y   h a n d l e s   c a s e - i n s e n s i t i v e   e n v i r o n m e n t   v a r i a b l e s .   6 .   T h e   n g i n x   m a i l i n g   l i s t   e v e n   h a d   a   P H P - s p e c i f i c   e x p l a n a t i o n .   7 .   D i s c u s s e d   i n   r e f e r e n c e   t o   C G I   s p e c i f i c a l l y .   i n n 0 t e a m i n n 0 t e a m
便 访 p o c 使
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则