Advanced Bash-Scripting Guide Example Script getopt_simple access control

CVSS Meta Temp Score
CVSS is a standardized scoring system to determine possibilities of attacks. The Temp Score considers temporal factors like disclosure, exploit and countermeasures. The unique Meta Score calculates the average score of different sources to provide a normalized scoring system.
Current Exploit Price (≈)
Our analysts are monitoring exploit markets and are in contact with vulnerability brokers. The range indicates the observed or calculated exploit price to be seen on exploit markets. A good indicator to understand the monetary effort required for and the popularity of an attack.
CTI Interest Score
Our Cyber Threat Intelligence team is monitoring different web sites, mailing lists, exploit markets and social media networks. The CTI Interest Score identifies the interest of attackers and the security community for this specific vulnerability in real-time. A high score indicates an elevated risk to be targeted for this vulnerability.
6.6$0-$5k0.00

Summaryinfo

A vulnerability was found in Advanced Bash-Scripting Guide Example Script. It has been classified as critical. Affected by this vulnerability is the function getopt_simple. The manipulation leads to access control. This vulnerability is listed as CVE-2019-9891. The attack must be carried out locally. In addition, an exploit is available. This vulnerability has a historic impact because of its background and how it was received. It is advisable to use the suggested workaround.

Detailsinfo

A vulnerability, which was classified as critical, has been found in Advanced Bash-Scripting Guide Example Script (unknown version). This issue affects the function getopt_simple. The manipulation with an unknown input leads to a access control vulnerability. Using CWE to declare the problem leads to CWE-264. Impacted is confidentiality, integrity, and availability. The summary by CVE is:

The function getopt_simple as described in Advanced Bash Scripting Guide (ISBN 978-1435752184) allows privilege escalation and execution of commands when used in a shell script called, for example, via sudo.

The bug was discovered 02/18/2019. The weakness was presented 03/26/2019 by RedTeam Pentesting (Patrick) with RedTeam Pentesting GmbH as [RT-SA-2019-007] Code Execution via Insecure Shell Function getopt_simple as not defined mailinglist post (Bugtraq). The advisory is shared at seclists.org. The identification of this vulnerability is CVE-2019-9891 since 03/20/2019. An attack has to be approached locally. The requirement for exploitation is a simple authentication. Technical details as well as a public exploit are known. The price for an exploit might be around USD $0-$5k at the moment (estimation calculated on 05/21/2020). MITRE ATT&CK project uses the attack technique T1068 for this issue. Due to its background and reception, this vulnerability has a historic impact. The following code is the reason for this vulnerability:

#!/bin/bash

getopt_simple()
{
    until [ -z "$1" ]
    do
      if [ ${1:0:2} = '--' ]
      then
          tmp=${1:2}               # Strip off leading '--' . . .
          parameter=${tmp%%=*}     # Extract name.
          value=${tmp##*=}         # Extract value.
          eval $parameter=$value
      fi
      shift
    done
}

target=/tmp

# Pass all options to getopt_simple().
getopt_simple $*

# list files to clean
echo "listing files in $target"
find "$target" -mtime 1
This is an interesting vulnerability because it does not affect an actual software implementation but an example script in a programming tutorial.

A public exploit has been developed by RedTeam Pentesting and been published immediately after the advisory. The exploit is available at seclists.org. It is declared as proof-of-concept. The vulnerability was handled as a non-public zero-day exploit for at least 2546 days. During that time the estimated underground price was around $0-$5k. The code used by the exploit is:

$ sudo -l
Matching Defaults entries for user on srv:
    env_reset, secure_path=/usr/sbin\:/usr/bin\:/sbin\:/bin

User www-data may run the following commands on srv:
    (root) NOPASSWD: /usr/local/sbin/cleanup.sh

The best possible mitigation is suggested to be Workaround. The mailinglist post contains the following remark:

Replace the function "getopt_simple" with the built-in function "getopts" or the program "getopt" from the util-linux package. Examples on how to do so are included in the same tutorial [3][4].

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Productinfo

Vendor

Name

CPE 2.3info

CPE 2.2info

CVSSv4info

VulDB Vector: 🔍
VulDB Reliability: 🔍

CVSSv3info

VulDB Meta Base Score: 7.6
VulDB Meta Temp Score: 7.2

VulDB Base Score: 5.3
VulDB Temp Score: 4.7
VulDB Vector: 🔍
VulDB Reliability: 🔍

NVD Base Score: 9.8
NVD Vector: 🔍

CVSSv2info

AVACAuCIA
💳💳💳💳💳💳
💳💳💳💳💳💳
💳💳💳💳💳💳
VectorComplexityAuthenticationConfidentialityIntegrityAvailability
UnlockUnlockUnlockUnlockUnlockUnlock
UnlockUnlockUnlockUnlockUnlockUnlock
UnlockUnlockUnlockUnlockUnlockUnlock

VulDB Base Score: 🔍
VulDB Temp Score: 🔍
VulDB Reliability: 🔍

NVD Base Score: 🔍

Exploitinginfo

Class: Access control
CWE: CWE-264
CAPEC: 🔍
ATT&CK: 🔍

Physical: Partially
Local: Yes
Remote: Yes

Availability: 🔍
Access: Public
Status: Proof-of-Concept
Author: RedTeam Pentesting
Download: 🔍

EPSS Score: 🔍
EPSS Percentile: 🔍

Price Prediction: 🔍
Current Price Estimation: 🔍

0-DayUnlockUnlockUnlockUnlock
TodayUnlockUnlockUnlockUnlock

Threat Intelligenceinfo

Interest: 🔍
Active Actors: 🔍
Active APT Groups: 🔍

Countermeasuresinfo

Recommended: Workaround
Status: 🔍

0-Day Time: 🔍
Exploit Delay Time: 🔍

Timelineinfo

04/05/2012 🔍
02/18/2019 +2510 days 🔍
03/20/2019 +30 days 🔍
03/20/2019 +0 days 🔍
03/20/2019 +0 days 🔍
03/26/2019 +6 days 🔍
03/26/2019 +0 days 🔍
03/27/2019 +1 days 🔍
05/21/2020 +421 days 🔍

Sourcesinfo

Advisory: [RT-SA-2019-007] Code Execution via Insecure Shell Function getopt_simple
Researcher: RedTeam Pentesting (Patrick)
Organization: RedTeam Pentesting GmbH
Status: Not defined

CVE: CVE-2019-9891 (🔍)
GCVE (CVE): GCVE-0-2019-9891
GCVE (VulDB): GCVE-100-132473
scip Labs: https://www.scip.ch/en/?labs.20161013

Entryinfo

Created: 03/27/2019 08:39
Updated: 05/21/2020 20:23
Changes: 03/27/2019 08:39 (73), 05/21/2020 20:23 (2)
Complete: 🔍
Cache ID: 216:172:103

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Discussion

No comments yet. Languages: en.

Please log in to comment.

Do you need the next level of professionalism?

Upgrade your account now!