Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-27850 PoC — Bypass of the fix for CVE-2019-0195

Source
Associated Vulnerability
Title:Bypass of the fix for CVE-2019-0195 (CVE-2021-27850)
Description:A critical unauthenticated remote code execution vulnerability was found all recent versions of Apache Tapestry. The affected versions include 5.4.5, 5.5.0, 5.6.2 and 5.7.0. The vulnerability I have found is a bypass of the fix for CVE-2019-0195. Recap: Before the fix of CVE-2019-0195 it was possible to download arbitrary class files from the classpath by providing a crafted asset file URL. An attacker was able to download the file `AppModule.class` by requesting the URL `http://localhost:8080/assets/something/services/AppModule.class` which contains a HMAC secret key. The fix for that bug was a blacklist filter that checks if the URL ends with `.class`, `.properties` or `.xml`. Bypass: Unfortunately, the blacklist solution can simply be bypassed by appending a `/` at the end of the URL: `http://localhost:8080/assets/something/services/AppModule.class/` The slash is stripped after the blacklist check and the file `AppModule.class` is loaded into the response. This class usually contains the HMAC secret key which is used to sign serialized Java objects. With the knowledge of that key an attacker can sign a Java gadget chain that leads to RCE (e.g. CommonsBeanUtils1 from ysoserial). Solution for this vulnerability: * For Apache Tapestry 5.4.0 to 5.6.1, upgrade to 5.6.2 or later. * For Apache Tapestry 5.7.0, upgrade to 5.7.1 or later.
Description
A Proof of concept for CVE-2021-27850 affecting Apache Tapestry and leading to unauthencticated remote code execution.
Readme
# CVE-2021-27850 Exploit #

## Overview ##

CVE-2021-27850 is a critical unauthenticated remote code execution vulnerability that was found in all recent versions of Apache Tapestry, by downloading the AppModule.class file we can leak the HMAC Secret key used to sign all the serialized objects in apache Tapestry.

We encountered this CVE in a real life assessment and as far as I know there are no public exploits available on how Tapestry signs the serialized objects so we decided to publish the following POC that we have used after digging in apache Tapestry source code for a long time x) .


## Usage ##

1- Clone this repo

2- Run the following command 

```sh
javac -classpath commons-codec-1.15/commons-codec-1.15.jar:. Exploit.java
```

3- Finally run the following:

```sh
java -cp commons-codec-1.15/commons-codec-1.15.jar:. Exploit [Tapestry Key] [Ysoserial Payload] [Command To Execute]
```

Where [Tapestry Key] is the Hmac key leaked from the AppModule.class , [Ysoserial Payload] is the payload you want to use from ysoserial and [Command To Execute] the command you want to execute.

![IMG](https://imgur.com/Je8bWC9.png)

**Note:** Unlike the usual Java deserialization exploits where the commands you run are limited ( no pipes or special chars .. ) you can use here any complex command you want since we are appending the following before executing the command ``` sh -c $@|sh . echo ``` .

**References:**

http://cve.mitre.org/cgi-bin/cvename.cgi?name=2021-27850

https://github.com/apache/tapestry-5
File Snapshot

[4.0K] /data/pocs/50ca14e4ccff8b72dea98d4026c733a609fb59a6 ├── [4.0K] commons-codec-1.15 │   ├── [4.0K] apidocs │   │   ├── [ 12K] allclasses-frame.html │   │   ├── [ 11K] allclasses-noframe.html │   │   ├── [ 27K] constant-values.html │   │   ├── [ 35K] deprecated-list.html │   │   ├── [8.8K] help-doc.html │   │   ├── [360K] index-all.html │   │   ├── [2.9K] index.html │   │   ├── [4.0K] org │   │   │   └── [4.0K] apache │   │   │   └── [4.0K] commons │   │   │   └── [4.0K] codec │   │   │   ├── [4.0K] binary │   │   │   │   ├── [ 19K] Base16.html │   │   │   │   ├── [ 20K] Base16InputStream.html │   │   │   │   ├── [ 20K] Base16OutputStream.html │   │   │   │   ├── [ 29K] Base32.html │   │   │   │   ├── [ 22K] Base32InputStream.html │   │   │   │   ├── [ 22K] Base32OutputStream.html │   │   │   │   ├── [ 50K] Base64.html │   │   │   │   ├── [ 23K] Base64InputStream.html │   │   │   │   ├── [ 23K] Base64OutputStream.html │   │   │   │   ├── [ 50K] BaseNCodec.html │   │   │   │   ├── [ 28K] BaseNCodecInputStream.html │   │   │   │   ├── [ 26K] BaseNCodecOutputStream.html │   │   │   │   ├── [ 27K] BinaryCodec.html │   │   │   │   ├── [ 10K] CharSequenceUtils.html │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   ├── [4.5K] Base16.html │   │   │   │   │   ├── [4.6K] Base16InputStream.html │   │   │   │   │   ├── [4.7K] Base16OutputStream.html │   │   │   │   │   ├── [4.5K] Base32.html │   │   │   │   │   ├── [4.6K] Base32InputStream.html │   │   │   │   │   ├── [4.7K] Base32OutputStream.html │   │   │   │   │   ├── [4.5K] Base64.html │   │   │   │   │   ├── [4.6K] Base64InputStream.html │   │   │   │   │   ├── [4.7K] Base64OutputStream.html │   │   │   │   │   ├── [9.5K] BaseNCodec.html │   │   │   │   │   ├── [7.7K] BaseNCodecInputStream.html │   │   │   │   │   ├── [7.7K] BaseNCodecOutputStream.html │   │   │   │   │   ├── [4.6K] BinaryCodec.html │   │   │   │   │   ├── [4.6K] CharSequenceUtils.html │   │   │   │   │   ├── [4.5K] Hex.html │   │   │   │   │   └── [4.6K] StringUtils.html │   │   │   │   ├── [ 64K] Hex.html │   │   │   │   ├── [2.7K] package-frame.html │   │   │   │   ├── [ 10K] package-summary.html │   │   │   │   ├── [ 11K] package-tree.html │   │   │   │   ├── [6.3K] package-use.html │   │   │   │   └── [ 52K] StringUtils.html │   │   │   ├── [ 10K] BinaryDecoder.html │   │   │   ├── [ 10K] BinaryEncoder.html │   │   │   ├── [ 20K] CharEncoding.html │   │   │   ├── [ 28K] Charsets.html │   │   │   ├── [4.0K] class-use │   │   │   │   ├── [ 11K] BinaryDecoder.html │   │   │   │   ├── [ 11K] BinaryEncoder.html │   │   │   │   ├── [4.5K] CharEncoding.html │   │   │   │   ├── [4.4K] Charsets.html │   │   │   │   ├── [ 20K] CodecPolicy.html │   │   │   │   ├── [ 26K] DecoderException.html │   │   │   │   ├── [ 14K] Decoder.html │   │   │   │   ├── [ 35K] EncoderException.html │   │   │   │   ├── [ 21K] Encoder.html │   │   │   │   ├── [4.4K] Resources.html │   │   │   │   ├── [8.0K] StringDecoder.html │   │   │   │   ├── [4.6K] StringEncoderComparator.html │   │   │   │   └── [ 17K] StringEncoder.html │   │   │   ├── [4.0K] cli │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   └── [4.5K] Digest.html │   │   │   │   ├── [ 12K] Digest.html │   │   │   │   ├── [ 865] package-frame.html │   │   │   │   ├── [5.5K] package-summary.html │   │   │   │   ├── [5.0K] package-tree.html │   │   │   │   └── [4.2K] package-use.html │   │   │   ├── [ 17K] CodecPolicy.html │   │   │   ├── [ 19K] DecoderException.html │   │   │   ├── [ 12K] Decoder.html │   │   │   ├── [4.0K] digest │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   ├── [4.5K] Crypt.html │   │   │   │   │   ├── [4.6K] DigestUtils.html │   │   │   │   │   ├── [ 12K] HmacAlgorithms.html │   │   │   │   │   ├── [4.6K] HmacUtils.html │   │   │   │   │   ├── [4.6K] Md5Crypt.html │   │   │   │   │   ├── [4.7K] MessageDigestAlgorithms.html │   │   │   │   │   ├── [4.6K] MurmurHash2.html │   │   │   │   │   ├── [4.6K] MurmurHash3.html │   │   │   │   │   ├── [4.8K] MurmurHash3.IncrementalHash32.html │   │   │   │   │   ├── [7.5K] MurmurHash3.IncrementalHash32x86.html │   │   │   │   │   ├── [4.6K] PureJavaCrc32C.html │   │   │   │   │   ├── [4.6K] PureJavaCrc32.html │   │   │   │   │   ├── [4.6K] Sha2Crypt.html │   │   │   │   │   ├── [4.6K] UnixCrypt.html │   │   │   │   │   └── [4.6K] XXHash32.html │   │   │   │   ├── [ 24K] Crypt.html │   │   │   │   ├── [212K] DigestUtils.html │   │   │   │   ├── [ 25K] HmacAlgorithms.html │   │   │   │   ├── [145K] HmacUtils.html │   │   │   │   ├── [ 44K] Md5Crypt.html │   │   │   │   ├── [ 28K] MessageDigestAlgorithms.html │   │   │   │   ├── [ 23K] MurmurHash2.html │   │   │   │   ├── [ 63K] MurmurHash3.html │   │   │   │   ├── [ 12K] MurmurHash3.IncrementalHash32.html │   │   │   │   ├── [ 14K] MurmurHash3.IncrementalHash32x86.html │   │   │   │   ├── [2.7K] package-frame.html │   │   │   │   ├── [ 12K] package-summary.html │   │   │   │   ├── [9.6K] package-tree.html │   │   │   │   ├── [6.6K] package-use.html │   │   │   │   ├── [ 15K] PureJavaCrc32C.html │   │   │   │   ├── [ 16K] PureJavaCrc32.html │   │   │   │   ├── [ 30K] Sha2Crypt.html │   │   │   │   ├── [ 20K] UnixCrypt.html │   │   │   │   └── [ 16K] XXHash32.html │   │   │   ├── [ 19K] EncoderException.html │   │   │   ├── [ 13K] Encoder.html │   │   │   ├── [4.0K] language │   │   │   │   ├── [ 17K] AbstractCaverphone.html │   │   │   │   ├── [4.0K] bm │   │   │   │   │   ├── [ 27K] BeiderMorseEncoder.html │   │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   │   ├── [4.8K] BeiderMorseEncoder.html │   │   │   │   │   │   ├── [8.5K] Lang.html │   │   │   │   │   │   ├── [9.3K] Languages.html │   │   │   │   │   │   ├── [ 23K] Languages.LanguageSet.html │   │   │   │   │   │   ├── [4.8K] Languages.SomeLanguages.html │   │   │   │   │   │   ├── [ 19K] NameType.html │   │   │   │   │   │   ├── [4.7K] PhoneticEngine.html │   │   │   │   │   │   ├── [ 12K] Rule.html │   │   │   │   │   │   ├── [ 10K] Rule.PhonemeExpr.html │   │   │   │   │   │   ├── [ 17K] Rule.Phoneme.html │   │   │   │   │   │   ├── [4.7K] Rule.PhonemeList.html │   │   │   │   │   │   ├── [8.7K] Rule.RPattern.html │   │   │   │   │   │   └── [ 18K] RuleType.html │   │   │   │   │   ├── [ 18K] Lang.html │   │   │   │   │   ├── [ 19K] Languages.html │   │   │   │   │   ├── [ 17K] Languages.LanguageSet.html │   │   │   │   │   ├── [ 20K] Languages.SomeLanguages.html │   │   │   │   │   ├── [ 19K] NameType.html │   │   │   │   │   ├── [2.6K] package-frame.html │   │   │   │   │   ├── [9.7K] package-summary.html │   │   │   │   │   ├── [9.5K] package-tree.html │   │   │   │   │   ├── [7.8K] package-use.html │   │   │   │   │   ├── [ 23K] PhoneticEngine.html │   │   │   │   │   ├── [ 37K] Rule.html │   │   │   │   │   ├── [8.9K] Rule.PhonemeExpr.html │   │   │   │   │   ├── [ 26K] Rule.Phoneme.html │   │   │   │   │   ├── [ 14K] Rule.PhonemeList.html │   │   │   │   │   ├── [8.4K] Rule.RPattern.html │   │   │   │   │   └── [ 19K] RuleType.html │   │   │   │   ├── [ 14K] Caverphone1.html │   │   │   │   ├── [ 14K] Caverphone2.html │   │   │   │   ├── [ 21K] Caverphone.html │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   ├── [7.2K] AbstractCaverphone.html │   │   │   │   │   ├── [4.6K] Caverphone1.html │   │   │   │   │   ├── [4.6K] Caverphone2.html │   │   │   │   │   ├── [4.6K] Caverphone.html │   │   │   │   │   ├── [4.6K] ColognePhonetic.html │   │   │   │   │   ├── [4.7K] DaitchMokotoffSoundex.html │   │   │   │   │   ├── [4.9K] DoubleMetaphone.DoubleMetaphoneResult.html │   │   │   │   │   ├── [4.6K] DoubleMetaphone.html │   │   │   │   │   ├── [4.8K] MatchRatingApproachEncoder.html │   │   │   │   │   ├── [4.6K] Metaphone.html │   │   │   │   │   ├── [4.6K] Nysiis.html │   │   │   │   │   ├── [7.0K] RefinedSoundex.html │   │   │   │   │   └── [8.0K] Soundex.html │   │   │   │   ├── [ 22K] ColognePhonetic.html │   │   │   │   ├── [ 21K] DaitchMokotoffSoundex.html │   │   │   │   ├── [ 19K] DoubleMetaphone.DoubleMetaphoneResult.html │   │   │   │   ├── [ 29K] DoubleMetaphone.html │   │   │   │   ├── [ 18K] MatchRatingApproachEncoder.html │   │   │   │   ├── [ 22K] Metaphone.html │   │   │   │   ├── [ 22K] Nysiis.html │   │   │   │   ├── [2.3K] package-frame.html │   │   │   │   ├── [9.0K] package-summary.html │   │   │   │   ├── [9.6K] package-tree.html │   │   │   │   ├── [6.3K] package-use.html │   │   │   │   ├── [ 25K] RefinedSoundex.html │   │   │   │   └── [ 35K] Soundex.html │   │   │   ├── [4.0K] net │   │   │   │   ├── [ 48K] BCodec.html │   │   │   │   ├── [4.0K] class-use │   │   │   │   │   ├── [4.5K] BCodec.html │   │   │   │   │   ├── [4.6K] PercentCodec.html │   │   │   │   │   ├── [4.5K] QCodec.html │   │   │   │   │   ├── [4.6K] QuotedPrintableCodec.html │   │   │   │   │   └── [4.5K] URLCodec.html │   │   │   │   ├── [1.3K] package-frame.html │   │   │   │   ├── [6.9K] package-summary.html │   │   │   │   ├── [7.9K] package-tree.html │   │   │   │   ├── [4.2K] package-use.html │   │   │   │   ├── [ 21K] PercentCodec.html │   │   │   │   ├── [ 48K] QCodec.html │   │   │   │   ├── [ 51K] QuotedPrintableCodec.html │   │   │   │   └── [ 41K] URLCodec.html │   │   │   ├── [2.6K] package-frame.html │   │   │   ├── [ 11K] package-summary.html │   │   │   ├── [8.9K] package-tree.html │   │   │   ├── [ 16K] package-use.html │   │   │   ├── [ 12K] Resources.html │   │   │   ├── [ 10K] StringDecoder.html │   │   │   ├── [ 20K] StringEncoderComparator.html │   │   │   └── [ 12K] StringEncoder.html │   │   ├── [1.5K] overview-frame.html │   │   ├── [6.1K] overview-summary.html │   │   ├── [ 29K] overview-tree.html │   │   ├── [ 218] package-list │   │   ├── [ 827] script.js │   │   ├── [4.8K] serialized-form.html │   │   ├── [4.0K] src-html │   │   │   └── [4.0K] org │   │   │   └── [4.0K] apache │   │   │   └── [4.0K] commons │   │   │   └── [4.0K] codec │   │   │   ├── [4.0K] binary │   │   │   │   ├── [ 26K] Base16.html │   │   │   │   ├── [8.2K] Base16InputStream.html │   │   │   │   ├── [8.2K] Base16OutputStream.html │   │   │   │   ├── [ 68K] Base32.html │   │   │   │   ├── [ 14K] Base32InputStream.html │   │   │   │   ├── [ 14K] Base32OutputStream.html │   │   │   │   ├── [ 87K] Base64.html │   │   │   │   ├── [ 14K] Base64InputStream.html │   │   │   │   ├── [ 14K] Base64OutputStream.html │   │   │   │   ├── [ 70K] BaseNCodec.html │   │   │   │   ├── [ 21K] BaseNCodecInputStream.html │   │   │   │   ├── [ 18K] BaseNCodecOutputStream.html │   │   │   │   ├── [ 29K] BinaryCodec.html │   │   │   │   ├── [8.0K] CharSequenceUtils.html │   │   │   │   ├── [ 58K] Hex.html │   │   │   │   └── [ 44K] StringUtils.html │   │   │   ├── [3.9K] BinaryDecoder.html │   │   │   ├── [3.8K] BinaryEncoder.html │   │   │   ├── [ 12K] CharEncoding.html │   │   │   ├── [ 17K] Charsets.html │   │   │   ├── [4.0K] cli │   │   │   │   └── [ 15K] Digest.html │   │   │   ├── [3.6K] CodecPolicy.html │   │   │   ├── [8.7K] DecoderException.html │   │   │   ├── [5.0K] Decoder.html │   │   │   ├── [4.0K] digest │   │   │   │   ├── [ 17K] Crypt.html │   │   │   │   ├── [156K] DigestUtils.html │   │   │   │   ├── [ 13K] HmacAlgorithms.html │   │   │   │   ├── [108K] HmacUtils.html │   │   │   │   ├── [ 39K] Md5Crypt.html │   │   │   │   ├── [ 16K] MessageDigestAlgorithms.html │   │   │   │   ├── [ 30K] MurmurHash2.html │   │   │   │   ├── [119K] MurmurHash3.html │   │   │   │   ├── [119K] MurmurHash3.IncrementalHash32.html │   │   │   │   ├── [119K] MurmurHash3.IncrementalHash32x86.html │   │   │   │   ├── [ 68K] PureJavaCrc32C.html │   │   │   │   ├── [ 68K] PureJavaCrc32.html │   │   │   │   ├── [ 61K] Sha2Crypt.html │   │   │   │   ├── [ 49K] UnixCrypt.html │   │   │   │   └── [ 19K] XXHash32.html │   │   │   ├── [8.9K] EncoderException.html │   │   │   ├── [4.5K] Encoder.html │   │   │   ├── [4.0K] language │   │   │   │   ├── [7.9K] AbstractCaverphone.html │   │   │   │   ├── [4.0K] bm │   │   │   │   │   ├── [ 20K] BeiderMorseEncoder.html │   │   │   │   │   ├── [ 23K] Lang.html │   │   │   │   │   ├── [ 26K] Languages.html │   │   │   │   │   ├── [ 26K] Languages.LanguageSet.html │   │   │   │   │   ├── [ 26K] Languages.SomeLanguages.html │   │   │   │   │   ├── [5.0K] NameType.html │   │   │   │   │   ├── [ 51K] PhoneticEngine.html │   │   │   │   │   ├── [ 69K] Rule.html │   │   │   │   │   ├── [ 69K] Rule.PhonemeExpr.html │   │   │   │   │   ├── [ 69K] Rule.Phoneme.html │   │   │   │   │   ├── [ 69K] Rule.PhonemeList.html │   │   │   │   │   ├── [ 69K] Rule.RPattern.html │   │   │   │   │   └── [4.7K] RuleType.html │   │   │   │   ├── [ 12K] Caverphone1.html │   │   │   │   ├── [ 13K] Caverphone2.html │   │   │   │   ├── [ 10K] Caverphone.html │   │   │   │   ├── [ 41K] ColognePhonetic.html │   │   │   │   ├── [ 53K] DaitchMokotoffSoundex.html │   │   │   │   ├── [ 95K] DoubleMetaphone.DoubleMetaphoneResult.html │   │   │   │   ├── [ 95K] DoubleMetaphone.html │   │   │   │   ├── [ 40K] MatchRatingApproachEncoder.html │   │   │   │   ├── [ 41K] Metaphone.html │   │   │   │   ├── [ 30K] Nysiis.html │   │   │   │   ├── [ 21K] RefinedSoundex.html │   │   │   │   └── [ 33K] Soundex.html │   │   │   ├── [4.0K] net │   │   │   │   ├── [ 28K] BCodec.html │   │   │   │   ├── [ 25K] PercentCodec.html │   │   │   │   ├── [ 33K] QCodec.html │   │   │   │   ├── [ 59K] QuotedPrintableCodec.html │   │   │   │   └── [ 35K] URLCodec.html │   │   │   ├── [4.2K] Resources.html │   │   │   ├── [3.8K] StringDecoder.html │   │   │   ├── [8.8K] StringEncoderComparator.html │   │   │   └── [3.8K] StringEncoder.html │   │   └── [ 13K] stylesheet.css │   ├── [346K] commons-codec-1.15.jar │   ├── [534K] commons-codec-1.15-javadoc.jar │   ├── [356K] commons-codec-1.15-sources.jar │   ├── [344K] commons-codec-1.15-tests.jar │   ├── [231K] commons-codec-1.15-test-sources.jar │   ├── [ 11K] LICENSE.txt │   ├── [ 733] NOTICE.txt │   └── [ 14K] RELEASE-NOTES.txt ├── [2.3K] Exploit.java ├── [1.5K] README.md └── [ 57M] ysoserial-master-d367e379d9-1.jar 30 directories, 281 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →