<分区>
这个问题似乎不是关于 a specific programming problem, a software algorithm, or software tools primarily used by programmers 的.如果您认为这个问题是关于 another Stack Exchange site 的主题,您可以发表评论以说明问题可能在哪里得到解答。
关闭 8 年前。
<分区>
这个问题似乎不是关于 a specific programming problem, a software algorithm, or software tools primarily used by programmers 的.如果您认为这个问题是关于 another Stack Exchange site 的主题,您可以发表评论以说明问题可能在哪里得到解答。
关闭 8 年前。
给定bash's remote code execution vulnerability announced on Sept 24 2014 ,如何使用 Ansible 更新基于 apt 的系统?
最佳答案
这是我在相当同质的环境中的首选解决方案。这样做的好处是将来更新不会花费很多时间,这与其他人使用的 version=latest
模式不同。
- name: update apt cache if not done today
apt: update_cache=yes cache_valid_time=86400
# http://seclists.org/oss-sec/2014/q3/650
- name: ensure secure ansible, ubuntu 1204 edition
apt: pkg=bash=4.2-2ubuntu2.5 state=present
when: ansible_distribution=='Ubuntu' and ansible_distribution_version=='12.04'
- name: ensure secure ansible, ubuntu 1404 edition
apt: pkg=bash=4.3-7ubuntu1.3 state=present
when: ansible_distribution=='Ubuntu' and ansible_distribution_version=='14.04'
# based on the following gist and comments below. there have been several exploits, this covers them well.
# https://gist.github.com/kacy/2b9408af04c71fab686e
- name: ensure bash is not vulnerable to 201409 problem
shell: "foo='() { echo not patched; }' bash -c foo"
register: command_result
ignore_errors: yes
failed_when: "'command not found' not in command_result.stderr"
说明:如果每天多次更新 apt-cache 是很昂贵的。可以调整缓存时间。代码实际测试以确保漏洞已修复 - 测试是好的。这将突出显示未包含在编码的发行版/版本中的任何主机。
SO 用户@jarv posted a great solution也。它不是总是更新 apt,而是仅在问题未解决时才这样做。这是最快的解决方案(至少在这个答案中)。 jarv 也有 added a distribution test in the linked repo ,对异构环境很有用。
- name: Check if we are vulnerable
shell: executable=/bin/bash env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
register: test_vuln
- name: Apply bash security update if we are vulnerable
apt: name=bash state=latest update_cache=true
when: "'vulnerable' in test_vuln.stdout"
- name: Check again and fail if we are still vulnerable
shell: executable=/bin/bash env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
when: "'vulnerable' in test_vuln.stdout"
register: test_vuln
failed_when: "'vulnerable' in test_vuln.stdout"
还有其他方法。 Ansible 的创建者 Michael DeHaan 和官方@ansible 帐户发布了一些解决方案:
ansible all -m apt -a 'update_cache=yes name=bash state=latest'
Here's a update-and-check solution :
- name: update apt
command: apt-get update
- name: update bash
command: apt-get --only-upgrade install bash
- name: check bash fix
command: env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
register: command_result
failed_when: "'error' not in command_result.stderr"
关于ubuntu - 使用 Ansible 和 apt,如何将 bash 更新为可远程利用的安全漏洞 CVE-2014-6271?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26024468/
相关文章:
python-3.x - 如何在 Spacy 中使用神经核函数
c - 如何有效地修补外部库并将其编译到 C 项目的 Makefile 中?
git - Ansible 任务 - 在没有 SSH 转发的情况下克隆私有(private) git
mysql - ubuntu 服务器 10.4 中缺少/tmp/mysql.socket 文件
linux - gdb 错误 - 文件不是可执行格式 : File format not recognized
python - 如何在 Python 中模拟 cx_Oracle 游标
cygwin - 当我尝试在 Windows/Cygwin 上使用 Ansible 配置 Vagrant VM 时,SSH 由于关键文件权限而失败