

Bash软件安全漏洞检测及解决方案
source link: http://abcdxyzk.github.io/blog/2014/09/26/debug-mark-bash/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Bash软件安全漏洞检测及解决方案
2014-09-26 10:16:00
http://www.techweb.com.cn/ucweb/news/id/2079505
redhat官方提供漏洞详情
A flaw was found in the way Bash evaluated certain specially crafted environment variables. An attacker could use this flaw to override or bypass environment restrictions to execute shell commands. Certain services and applications allow remote unauthenticated attackers to provide environment variables, allowing them to exploit this issue.
redhat官方提供检测方式
运行命令:
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
如果返回以下内容:则请尽快升级。
vulnerable
this is a test
http://seclists.org/oss-sec/2014/q3/650
The technical details of the vulnerability follow.
Bash supports exporting not just shell variables, but also shell functions to other bash instances, via the process environment to (indirect) child processes. Current bash versions use an environment variable named by the function name, and a function definition starting with “() {” in the variable value to propagate function definitions through the environment. The vulnerability occurs because bash does not stop after processing the function definition; it continues to parse and execute shell commands following the function definition. For example, an environment variable setting of
VAR=() { ignored; }; /bin/id
will execute /bin/id when the environment is imported into the bash process. (The process is in a slightly undefined state at this point. The PATH variable may not have been set up yet, and bash could crash after executing /bin/id, but the damage has already happened at this point.)
The fact that an environment variable with an arbitrary name can be used as a carrier for a malicious function definition containing trailing commands makes this vulnerability particularly severe; it enables network-based exploitation.
So far, HTTP requests to CGI scripts have been identified as the major attack vector.
A typical HTTP request looks like this:
GET /path?query-param-name=query-param-value HTTP/1.1
Host: www.example.com
Custom: custom-header-value
The CGI specification maps all parts to environment variables. With Apache httpd, the magic string “() {” can appear in these places:
- Host (“www.example.com”, as REMOTE_HOST)
- Header value (“custom-header-value”, as HTTP_CUSTOM in this example)
- Server protocol (“HTTP/1.1”, as SERVER_PROTOCOL)
The user name embedded in an Authorization header could be a vector as well, but the corresponding REMOTE_USER variable is only set if the user name corresponds to a known account according to the authentication configuration, and a configuration which accepts the magic string appears somewhat unlikely.
In addition, with other CGI implementations, the request method (“GET”), path (“/path”) and query string (“query-param-name=query-param-value”) may be vectors, and it is conceivable for “query-param-value” as well, and perhaps even “query-param-name”.
The other vector is OpenSSH, either through AcceptEnv variables, TERM or SSH_ORIGINAL_COMMAND.
Other vectors involving different environment variable set by additional programs are expected.
Posted by kk
Recommend
-
44
-
12
浅谈代码静态检测中SQL注入的安全漏洞 SQL注入: SQL是操作数据库数据的结构化查询语言,网页的应用数据和后台数据库中的数据进行交互时会采用SQL。 SQL注入,就是通过把SQL命...
-
8
IoT设备安全漏洞分析、挖掘、检测和缓解综述 阅读量 71896...
-
11
Vice Society正利用PrintNightmare安全漏洞注入勒索软件 思科 Talos 威胁情报研究团队在一份新报告中指出:微软的 PrintNightmare 安全漏洞,现正被一个名为 Vice Society 的勒索软件团伙所利用。近段时间,Talos 团队一直...
-
14
bash: npm: command not found 的一种解决方案 由于我使用 n 来管理多个 node.js 版本,所以当报错如下的时候 /bin/bash: npm: command not found 我有猜测是不是 /bin/bash 找不到相关命令 使用...
-
4
PHP 检测文件编码的不完美解决方案 因为某些原因现在需要批量检测文件编码,看看是不是有非 UTF-8 文件混在其中 我当然是首选了我最熟悉的 PHP,感觉应该很简单 google 搜索 php detect encoding,第一...
-
31
aetkrad/goby_poc: goby poc or exp,分享goby最新网络安全漏洞检测或利用代码 Files
-
9
最全常见Web安全漏洞总结及推荐解决方案常见Web安全漏洞总结及推荐解决方案目录:1.SQL注入:
-
4
粮食检测综合解决方案企业高哲信息获数千万A轮融资,以AI代替人工 作者:麦乐迪 发布时间: 2022-12-07 15:30
-
10
“蓝空天末,孤星遥坠。满街游走,打听幸福。” Bash脚本DLC:Bash语法和URL检测脚本实例 其实之前写过一篇bash脚本的文章:
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK