KeyChecker: "key_ops" does not tell content decryption from key unwrapping, and "deriveKey"/"deriveBits" are not accepted on both sides

Open
#761 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
security

Research direction

Start by reading KeyChecker::checkKeyUsage() and tracing the encryption and decryption paths for dir and ECDH-ES. The issue specifies the expected dir operations and that deriveKey and deriveBits should both work on either side for key agreement. Check the existing tests for those modes and add coverage showing those cases pass while wrapping-only keys cannot decrypt dir content.

Written by the indexing model from the issue text.

Description

enhancement
Version(s) affected

All released versions (3.4.x, 4.0.x, 4.1.x, 4.2.x), and the 4.3.x and 5.0.x branches.

Description

KeyChecker::checkKeyUsage() accepts any of decrypt, unwrapKey and deriveBits for every decryption, and any of encrypt, wrapKey and deriveKey for every encryption, whatever the key management mode. Two consequences:

  • A key restricted to ["wrapKey", "unwrapKey"], meant for key wrapping only, can still decrypt dir content. key_ops therefore does not prevent the key confusion described in #760.
  • The two lists disagree for key agreement: a key restricted to deriveKey can encrypt with ECDH-ES but cannot decrypt, and a key restricted to deriveBits can decrypt but cannot encrypt.
Possible Solution
  • 4.3.0: dir requires encrypt when building and decrypt when decrypting; deriveKey and deriveBits are both accepted on both sides for key agreement.
  • A strict mapping per key management mode would refuse keys exported by WebCrypto (for example AES-GCM keys with encrypt/decrypt used for A*GCMKW, RSA keys with decrypt used for RSA-OAEP, or ECDH public keys exported with an empty key_ops). It is left for 5.0.0, if at all.
Additional Context

Found by the Anthropic OSS Scanner (ANT-2026-Z8KOO4J9).

Dominant language
PHP
Stars
954
Forks
119
Avg merge
48m
Merged PRs (30d)
17

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web-token/jwt-framework

All issues in web-token/jwt-framework

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.