e: or any signed MSI from a compromised system, like happened to Palemoon last year: https://news.ycombinator.com/item?id=20435699
Endless rabbit-hole of course but that's already a lot of low-hanging fruit
Think of the legitimate MSI and malicious JAR files as separate short stories in the same book. The 'book' comes to your computer claiming to be one thing (the legitimately signed MSI) but the second chapter is something completely different (the malicious jar file). When your computer reads the book (calculates and verifies the signature) it only does it off the first chapter. That lets the second part slide under the additional scrutiny Windows applies to files downloaded from the Internet.
However, this blog post mentions that various security solutions trust the windows code signing, but it does not mention which ones - https://blog.virustotal.com/2019/01/distribution-of-maliciou...
Wtf? Am I reading this right, if part of the file is signed by MS then it just doesn't bother running it through the detection algo?
That looks exceedingly like a designed in security hole.
Presumably paired with the OP "bug" means MS could, with an NSA letter say, drop malware on devices if those devices were using Windows Defender for AV.
Just as well MS don't snoop on what software user's are running./s
“ Digitally signed files are more trusted by the Operating System. This higher trust allows such files to execute in sensitive contexts or excluded from Antivirus scans.”
It seems that msi installer packages with a trusted code signature (1) are excluded from scans by various antivirus protections. Which kind of makes sense: driver packages may contain code that would trigger heuristics a lot.
> Presumably paired with the OP "bug" means MS could, with an NSA letter say, drop malware on devices if those devices were using Windows Defender for AV.
Microsoft can already do that. To be quite honest - pretty much every institution with the right signing powers can on practically all OS. Have you verified the latest chrome installer package?
This bug seems to allow something more insidious: you could download the latest google chrome msi and append your payload jar to that msi and redistribute it. The signature remains valid. This allows bypassing the code signing checks even if you have no code signing powers.
(1) not from Microsoft, Microsoft only hands out the certificates, the signing is done by the developer
And no, that’s not how the NSA works.
Isn't it like having a special 'I know my bag smells like drugs to sniffer dogs but I promise I don't have drugs' channel at airport arrivals; and when people go down that channel you don't bother to check their bags.
They don’t treat concatenated malicious files as safe, they trust that files signed by MS are safe. You aren’t supposed to be able to concatenate a file and still have the signature check out. That’s the bug.
If you want a good reason why, ask McAfee about the time that they incorrectly detected svchost.exe as a virus and made every customer’s windows machine around the world unbootable.
- Headers describing a section, including the length of a section.
- Prefixing each section with a size.
- Using a marker pattern (such as a null byte) to mark the end of a section of data.
(there are more than these three, but these are the most common)
That last one isn't used very often, and when it is, it's mostly for textual data.The consequence of using the first two techniques is that it's entirely possible to add data to the end of the format, since a parser would just read the last section and stop (assuming the format supports knowing what the last section is).
I developed something like this to put an md5 hash in a comment in the first line of a code module at a place I worked. It simply read the file, removed that line, and hashed the rest of the file data to generate the hash for comparison.
This was just to stop programmers changing the code without submitting it to a secondary system for validation/tracking (easy to work around, but that shows intent to bypass policies when we see it in the repo).
1) Take MicrosoftSigned.Msi
2) Append Malway.jar to it
3) Take file and rename it as RunMe.Jar
# Now you have a jar file that appears to be signed by Microsoft but contains malways.
4. Give target RunMe.jar and ask then to dbl-click it.
# Usually this file would prompt the user with a "You shouldn't trust this arbitrary file from the internet" prompt, but it doesn't because Windows thinks this file is correctly signed
5. Target is now infected
Or, even better, simultaneously put a silent drive-by browser zero-day in a website they visit regularly, like https://googleprojectzero.blogspot.com/2019/08/a-very-deep-d...
The attacker can drop/ exec files as they please, regardless of whether they're signed.
Anyone can feel free to correct me.
I know this can be done w/ Cat.
--Wow, so JAR files are read from bottom top so it literally masquerades.
That's interesting.
Zips can also be read from front to back, reading the header of each entry and skipping the compressed data to the next header, which is most of what zip repair utilities do (or did, not sure anyone repairs zips any more). But it's faster to read the index.
And to be clear, jars are zip files.
If they do claim it then they should properly verify signatures
Either way is wrong.
That's crazy the signature check wouldn't verify the file length.
Windows still sees it as a MSI file while doing signature checking. But because it has a .jar extension, the JRE runs it when you double click.
Signature verification is done as a independent check, completely separate from execution. Because windows needs to know the signature is valid before even allowing the file to be executed. It also needs to show the signature check in the right-click -> properties dialog.
'Quintero said this weakness would particularly acute if an attacker were to use it to hide a malicious Java file (.jar). And, he said, this exact attack vector was indeed detected in a malware sample sent to VirusTotal.
“In short, an attacker can append a malicious JAR to a MSI file signed by a trusted software developer (like Microsoft Corporation, Google Inc. or any other well-known developer), and the resulting file can be renamed with the .jar extension and will have a valid signature according Microsoft Windows,” Quintero wrote.'
In terms of practical impact, it sounds like you need a target where the JAR file will be run, but also where you'd expect Windows signatures validation alone to protect against malicious Jars.
"foo\u200fism.jar" (\u is the Python escape for arbitrary unicode codepoints)
And Windows will (as of a couple years ago, at least) render it as "fooraj.msi"
(Though I'm not sure what kind of verification prompt you'd get in this circumstance)
Here are a bunch of great real-life examples from the Playstation 4 hacking scene: https://www.psdevwiki.com/ps4/Working_Exploits
Or iOS exploit chains, some of which I've used intentionally as part of iOS jailbreak tools like unc0ver. From Project Zero's "very deep dive into iOS Exploit chains found in the wild": "Earlier this year Google's Threat Analysis Group (TAG) discovered a small collection of hacked websites. The hacked sites were being used in indiscriminate watering hole attacks against their visitors, using iPhone 0-day." https://googleprojectzero.blogspot.com/2019/08/a-very-deep-d...
I imagine the real-world application of this MSI thing is something like:
1) Get silently-malicious MSI on to target machine (via download server compromise, poisoned non-TLS download, redirect TLS-downgrade, etc etc)
2) Got malicious "trigger" exploit code on to any web page used by the target (via web server compromise, weak human security like admin passwords, etc etc).
3) There is no step three.
With this in mind we can look at even very recent real-world news—like the simultaneous patching of five Chrome exploits in June 2020—and instantly see how it's not just hypothetical: https://www.cisecurity.org/advisory/multiple-vulnerabilities...
For example, one of them (CVE-2020-6493) is "Use after free in WebAuthentication in Google Chrome prior to 83.0.4103.97 allowed a remote attacker who had compromised the renderer process to potentially perform a sandbox escape via a crafted HTML page". How many more of these do you think are hanging around out there, waiting for Google to get the 'okay' to fix?
a) A separate vulnerability that provides arbitrary code execution to run your trigger exploit
or
b) A vulnerability that allows you to execute a specific program/command on the target system
If you've got either of those, the ability to run a pre-existing JAR doesn't really increase your capabilities. You've already got at least user-level access. Having a way to distribute a malicious JAR in advance might be useful in some cases, but having a file sitting on disk in advance significantly increases the risk of having your exploit detected before you get to use it.
It strikes me that the primary use for this would be attacking a target that (1) has some level of system lockdown/scanning such that signing is required, (2) has Java installed on computers and uses it (not just a program that bundles in its own JRE), (3) has scanners vulnerable to the signature validation bug that assume signature OK == safe, (4) has some sort of network scanning IPS/IDS such that the "run malware" trigger needs to be small to avoid detection.
If (1) isn't the case, then there are probably easier ways to sneak your malware into position. If (2) isn't the case, your malware can't run. If (3) isn't the case, your attack risks getting detected in advance and burning any chance of using it. If (4) isn't the case, you'd probably be better off delivering the full malware via the browser sandbox escape/whatever network exploit you're using to avoid needing 1-3 in place first.
I would venture the guess that this has been used for (1) opportunistic malware intended for wide distribution with a low probability of any given target being compromised due to requiring the user to run the malicious JAR and (2) very targeted attacks on specific institutions that meet the 1-4 criteria.
I would actually expect a number of interesting institutions to match that profile - places likely to keep systems updated (or at least updated AV), so not guaranteed to be vulnerable to last month's patched bugs, who have some level of system lockdown and scanning such that hiding in plain sight behind file signature verification is necessary, who have some type of IDS/IPS such that the separate trigger needs to be kept to a minimum, and who rely on a set rather poorly packaged Java software. I'm sure the list of targets matching those criteria includes a number of financial institutions and infrastructure operators - targets that need to pay more that trivial lip-service to security, but where security is a "we've checked all the boxes so we're good" mindset.
This can depend on your country. Here in Brazil, the income tax preparation software (http://receita.economia.gov.br/interface/cidadao/irpf/2020/d...) is written in Java, and the install instructions in that page tell you to update Java, so it's probably not bundled. Since everyone with income above a certain amount (and several other situations) has to use that software to fill the tax report (the option to use the paper form has been discontinued many years ago), I'd guess a high number of personal Windows users in this country have Java installed.
You can damage most software vendors with just #1.
Then #2 is even worse.
#3 you already own them because #1,#2 let you download a poisoned msi to the machine. You can get cleaver and dynamically change the hash per download as described year ago when signature based AV was all we had, you dont need this trick.
Or... you could just drop powershell, python and execute it and own the machine without trying so hard with just #1 and #2.
Yes on your first part; no on the parenthetical. One exploit to let the malicious hanger-on into your computer. Another exploit—maybe in a web page you visit regularly—to trigger it. Compare to this real-world iOS attack: https://googleprojectzero.blogspot.com/2019/08/a-very-deep-d...
Here are twenty-three of them to get you started: https://github.com/arntsonl/calc_security_poc
One of the top ranking hackthebox players summarized PlayerTwo quite neatly [1].
[1] https://www.youtube.com/watch?v=u_GkIzCmU90 (13 min.)
Funnily enough this is exactly how real attacks tend to work https://googleprojectzero.blogspot.com/2019/08/a-very-deep-d...
1) Take signed .MSI
2) Add my JAR of malware to the end of it
3) Send file to target
4) Target's computer recognizes the file as a signed MSI, ignoring the extra stuff at the end that's not part of the MSI
5) Target computer calls the JRE to launch the JAR
6) JRE ignores the MSI parts at the beginning of the file because compressed JAR files are loaded back-to-front
Obviously a major bug that signature validation ignores "extra" parts of the file, but a signature validation bug that (1) only affects specific types of files executed by a third-party runtime and (2) doesn't threaten system files (or any native executables at all) isn't an obviously critical vulnerability like an arbitrary "signature validation is totally broken" bug.