jira/apps/api/plane/app/serializers
Manish Gupta 30527927d7
[WEB-8103] fix: stop leaking webhook HMAC secret_key on reads (#9382)
* [WEB-8103] fix: stop leaking webhook HMAC secret_key on reads (GHSA-83rj)

WebhookEndpoint list/retrieve/patch pass a fields= allowlist that excludes
secret_key, but DynamicBaseSerializer.__init__ discards the caller
allowlist (fields = self.expand). With WebhookSerializer using
fields="__all__" and secret_key only in read_only_fields (read-only is
still serialized), the HMAC signing secret leaked on every webhook read
(GHSA-83rj-4282-x39v; admin-only).

Rather than secret_key = CharField(write_only=True) — which would let a
client inject their own secret on create/patch and break the intended
one-time reveal — hide it by default and reveal only where intended:

- WebhookSerializer.to_representation drops secret_key unless the
  show_secret_key context flag is set (secure by default). secret_key
  stays server-generated (default=generate_token) and non-writable.
- POST create and WebhookSecretRegenerateEndpoint pass show_secret_key so
  the secret is still returned once for the caller to configure their
  receiver; list/retrieve/patch no longer emit it.

Add contract regression tests (fail-before verified). Follow-up: the
DynamicBaseSerializer.__init__ allowlist bug affects other serializers —
tracked separately.

Co-authored-by: Plane AI <noreply@plane.so>

* [WEB-8103] test: address review — patch network boundary + pin to_representation

Per review (@sriramveeraghanta):
- Patch the network boundary (validate_url) instead of the whole private
  _validate_webhook_url method, so the domain/schema checks still run and
  the test survives a rename of the private method.
- Add an assertion that an explicit fields=("secret_key",) request still
  hides the key, pinning to_representation as the enforcement point so a
  future DynamicBaseSerializer._filter_fields fix can't silently re-open
  the leak.

Co-authored-by: Plane AI <noreply@plane.so>

* [WEB-8103] docs: spell out both levels of the dead fields= allowlist

The previous comment named only DynamicBaseSerializer.__init__ discarding the
caller's fields=, which is half the root cause. _filter_fields never removes
anything either: it builds `allowed` purely to attach expansion serializers for
names not already on the serializer, then returns self.fields unfiltered
(serializers/base.py:45-119).

So the fields= kwargs in views/webhook/base.py are no-ops on two independent
levels. Documented so a future `fields = fields or self.expand` fix isn't
assumed to re-activate the allowlists for confidentiality — _filter_fields has
to be made restrictive first. The show_secret_key context flag remains the sole
enforcement point.

Addresses @sriramveeraghanta's review on #9382. 6/6 contract tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(security): drop advisory identifiers from code comments

Explanations kept unchanged; only the IDs are removed.

Co-authored-by: Plane AI <noreply@plane.so>

---------

Co-authored-by: Plane AI <noreply@plane.so>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 00:16:01 +05:30
..
__init__.py [WEB-7855] fix(security): prevent project invite email disclosure via unauthenticated GET (#9305) 2026-07-01 17:34:45 +05:30
analytic.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
api.py refactor: logging with retention + API token hardening (#9148) 2026-05-27 16:00:05 +05:30
asset.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
base.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
cycle.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
draft.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
estimate.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
exporter.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
favorite.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
importer.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
intake.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
issue.py [WEB-7774] fix(security): sanitize comment_html and intake description_html with nh3 (#9287) 2026-06-23 17:52:31 +05:30
module.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
notification.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
page.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
project.py [WEB-7855] fix(security): prevent project invite email disclosure via unauthenticated GET (#9305) 2026-07-01 17:34:45 +05:30
state.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
user.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
view.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
webhook.py [WEB-8103] fix: stop leaking webhook HMAC secret_key on reads (#9382) 2026-08-28 00:16:01 +05:30
workspace.py [WEB-7854] fix: prevent workspace invite token disclosure and invite hijack (#9297) 2026-06-23 17:47:16 +05:30