owncloud / owncloud/ocis-workflows

hooks: read-then-write race on first-save webhook token generation

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

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
0
Forks
0
Avg merge
3d 23h
Merged PRs (30d)
9

Description

Follow-up from review on #30 (feat(backend): add webhook trigger).

In syncTriggerIndex (workflows.go), the webhook case does GetTriggerIndexEntry → if empty, generate a token → Upsert, with no transaction/locking. Two concurrent first-saves of the same new workflow could each generate a different token and race on the upsert, silently discarding one — indistinguishable from an unrequested rotation.

This is a narrow window: the frontend save button is :disabled="saving" for the duration of the request, so triggering it requires two genuinely separate save actions racing at the network level, not a simple double-click. That's why it wasn't fixed as part of #30 — not worth bolting on new locking/SQL surface speculatively for a low-likelihood race.

Possible fixes, if this turns out to matter in practice:

  • Wrap syncTriggerIndex's webhook case in a mutex (cheap, but only helps within a single process).
  • An atomic "preserve existing token" SQL upsert, distinct from RotateWebhookToken's deliberate overwrite — would need its own query.

Contributor guide

Open the contributing guide

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.

Research direction

Read syncTriggerIndex in workflows.go, focusing on the webhook path from GetTriggerIndexEntry through token generation and Upsert. Compare this with RotateWebhookToken and determine the project’s concurrency and persistence conventions before choosing a fix. Done means concurrent first saves preserve one token without silently treating the race as a rotation, with regression coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.