ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-10 Thread Eirik Bjørsnøs
Hi, ZipFile.isSignatureRelated currently returns true for paths such as the following: META-INF/libraries/org.bouncycastle:bcprov-jdk15on:jar-1.70/META-INF/BC2048KE.DSA While this path does start with "META-INF/" and ends with ".DSA", the file does not live in the META-INF/ directory _directly_,

Re: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-12 Thread Eirik Bjørsnøs
> > ZipFile.isSignatureRelated currently returns true for paths such as the > following: > > > META-INF/libraries/org.bouncycastle:bcprov-jdk15on:jar-1.70/META-INF/BC2048KE.DSA > I found a couple more call sites of SignatureFileVerifier.isBlockOrSF which incorrectly treat [SF,DSA,RSA,EC] files as

Re: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-13 Thread Alan Bateman
Forwarding to security-dev as that is where issues around signed JARs are usually discussed. -Alan. On 10/01/2023 17:00, Eirik Bjørsnøs wrote: Hi, ZipFile.isSignatureRelated currently returns true for paths such as the following: META-INF/libraries/org.bouncycastle:bcprov-jdk15on:jar-1.

RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-13 Thread Eirik Bjorsnos
Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that files reside in META-INF directly, and not in a subdirectory of META-INF. The mentioned call sites needs updates to check and ignore such files. A new test VerifyUnrelatedSignatureFiles is added which verifies that [*.SF,

Integrated: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-27 Thread Eirik Bjorsnos
penjdk.org/jdk/commit/5dfc4ec7d94af9fe39fdee9d83b06101b827a3c6 Stats: 429 lines in 6 files changed: 405 ins; 8 del; 16 mod 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories Reviewed-by: weijun - PR: https://git.openjdk.org/jdk/pull/11976

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-13 Thread Weijun Wang
On Thu, 12 Jan 2023 18:44:26 GMT, Eirik Bjorsnos wrote: > Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new te

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-14 Thread Eirik Bjorsnos
On Fri, 13 Jan 2023 22:31:28 GMT, Weijun Wang wrote: >> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that >> files reside in META-INF directly, and not in a subdirectory of META-INF. >> >> The mentioned call sites needs updates to check and ignore such files. >> >> A new

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories

2023-01-14 Thread Eirik Bjorsnos
On Fri, 13 Jan 2023 22:36:01 GMT, Weijun Wang wrote: >> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that >> files reside in META-INF directly, and not in a subdirectory of META-INF. >> >> The mentioned call sites needs updates to check and ignore such files. >> >> A new

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v2]

2023-01-14 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v2]

2023-01-14 Thread Eirik Bjorsnos
On Fri, 13 Jan 2023 22:36:47 GMT, Weijun Wang wrote: >> Eirik Bjorsnos has updated the pull request with a new target base due to a >> merge or a rebase. The incremental webrev excludes the unrelated changes >> brought in by the merge/rebase. The pull request contains six additional >> commits

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v3]

2023-01-15 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v3]

2023-01-15 Thread Eirik Bjorsnos
On Sat, 14 Jan 2023 13:17:32 GMT, Eirik Bjorsnos wrote: >> test/jdk/java/util/jar/JarFile/VerifyUnrelatedSignatureFiles.java line 61: >> >>> 59: File j = createJarFile(); >>> 60: File s = signJarFile(j, "signed"); >>> 61: File m = moveSignatureRelated(s); >> >> Try sign

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v4]

2023-01-15 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v5]

2023-01-15 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v6]

2023-01-16 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v6]

2023-01-17 Thread Weijun Wang
On Sat, 14 Jan 2023 12:14:54 GMT, Eirik Bjorsnos wrote: >> src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java line 980: >> >>> 978: * Returns true iff the entry resides directly in the META-INF/ >>> directory >>> 979: */ >>> 980: private boolean isInMetaInf(ZipEnt

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v6]

2023-01-17 Thread Weijun Wang
On Sat, 14 Jan 2023 12:02:11 GMT, Eirik Bjorsnos wrote: >> src/java.base/share/classes/java/util/zip/ZipFile.java line 1748: >> >>> 1746: .isBlockOrSF(new String(name, off, len, >>> UTF_8.INSTANCE) >>> 1747: .toUpperCase(Locale.ENGLISH))); >>> 1748: >> >> H

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v7]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v7]

2023-01-18 Thread Eirik Bjorsnos
On Tue, 17 Jan 2023 16:46:28 GMT, Weijun Wang wrote: >> I started there, but ran into some problems: >> >> SignatureFileVerifier.isSigningRelated calls isBlockOrSF, but it removes the >> "META-INF/" prefix from the path first. So we can't assume that input to >> isBlockOrSF is the full path. >

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v7]

2023-01-18 Thread Eirik Bjorsnos
On Wed, 18 Jan 2023 09:47:29 GMT, Eirik Bjorsnos wrote: >> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that >> files reside in META-INF directly, and not in a subdirectory of META-INF. >> >> The mentioned call sites needs updates to check and ignore such files. >> >> A

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v7]

2023-01-18 Thread Eirik Bjorsnos
On Tue, 17 Jan 2023 16:11:42 GMT, Weijun Wang wrote: >> This duplicated check annoyed me also, but the existing checks have >> different behavior: >> >> - JarVerifier.beginEntry normalizes the path to uppercase, them checks that >> it starts with "META-INF/" or "/META-INF/" >> - JarSigner.sign

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v8]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v9]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v10]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v11]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v11]

2023-01-18 Thread Eirik Bjorsnos
On Wed, 18 Jan 2023 09:51:35 GMT, Eirik Bjorsnos wrote: >> While `JarSigner` has not normalize to uppercase, the check is the same. As >> for `/META-INF/`, it must be very broken now since >> `JarFile::maybeInstantiateVerifier` is using >> `JUZFA.getManifestName(this,true)` to read the manifes

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v11]

2023-01-18 Thread Eirik Bjorsnos
On Wed, 18 Jan 2023 12:57:17 GMT, Eirik Bjorsnos wrote: >> I agree this deserves a cleanup, and since we're already deep into it it can >> make sense to fix this in this PR. >> >> I have introduced SignatureFileVerifier.isInMetaInf as a common method to >> replace duplicated logic in JarVerifi

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v12]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v13]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v14]

2023-01-18 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test VerifyUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v14]

2023-01-18 Thread Eirik Bjorsnos
On Wed, 18 Jan 2023 13:42:12 GMT, Eirik Bjorsnos wrote: >> When introducing the call to isInMetaInf in isSigningRelated, I accidentally >> broke the matching of MANIFEST.MF and SIG-* files. >> >> When fixing this regression, I now match against the full path instead of >> the existing prefix s

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v15]

2023-01-24 Thread Eirik Bjorsnos
> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that > files reside in META-INF directly, and not in a subdirectory of META-INF. > > The mentioned call sites needs updates to check and ignore such files. > > A new test IgnoreUnrelatedSignatureFiles is added which verifies t

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v15]

2023-01-24 Thread Weijun Wang
On Tue, 24 Jan 2023 12:31:30 GMT, Eirik Bjorsnos wrote: >> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that >> files reside in META-INF directly, and not in a subdirectory of META-INF. >> >> The mentioned call sites needs updates to check and ignore such files. >> >> A

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v15]

2023-01-24 Thread Eirik Bjorsnos
On Tue, 24 Jan 2023 18:54:59 GMT, Weijun Wang wrote: > Precisely `ZipFile::isSignatureRelated` should also contain those `SIG-` > files. Should they though? These files are ultimately read by JarFile.initializeVerifier, which I guess only cares about signature/block files it actually knows

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v15]

2023-01-27 Thread Weijun Wang
On Tue, 24 Jan 2023 12:31:30 GMT, Eirik Bjorsnos wrote: >> Some call sites of SignatureFileVerifier.isBlockOrSF fails to check that >> files reside in META-INF directly, and not in a subdirectory of META-INF. >> >> The mentioned call sites needs updates to check and ignore such files. >> >> A

Re: RFR: 8300140: ZipFile.isSignatureRelated returns true for files in META-INF subdirectories [v15]

2023-01-27 Thread Eirik Bjorsnos
On Fri, 27 Jan 2023 22:16:18 GMT, Weijun Wang wrote: > Maybe we can rename `ZipFile::isSignatureRelated` to `ZipFile::isBlockOrSF` > as well? The term "signature related" seems to be used quite extensively around ZipFile and also in JavaUtilZipFileAccess. Semantics are very similar, but not ex