Skip to content

fix: restrict order_delay_notification to authorized users with KOT read permissions - #234

Draft
esafwan wants to merge 1 commit into
developfrom
task/SweepSecurity-SEC-19-impl-1
Draft

fix: restrict order_delay_notification to authorized users with KOT read permissions#234
esafwan wants to merge 1 commit into
developfrom
task/SweepSecurity-SEC-19-impl-1

Conversation

@esafwan

@esafwan esafwan commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What it does / Summary

Restricts the whitelisted order_delay_notification API endpoint in ury/ury/api/ury_kot_notification.py to users who possess read permission on the target URY KOT document, and adds unit test coverage.

What it solves / Motivation

  • Resolves security finding SEC-19 by preventing arbitrary authenticated users from spamming manager Notification Logs by passing arbitrary KOT IDs to order_delay_notification.
  • Guarantees that non-existent KOT IDs trigger immediate validation errors and unauthorized callers receive a permission error.

Key Technical Changes

  • Authorization Guard (ury/ury/api/ury_kot_notification.py):
    • Added _get_authorized_kot(kot_id) helper that checks KOT existence (throwing ValidationError if missing) and verifies kot.has_permission("read") (throwing PermissionError if unauthorized).
    • Updated order_delay_notification to load document attributes cleanly from _get_authorized_kot(id) instead of making redundant single-field DB queries.
  • Unit Test Suite (ury/ury/api/test_ury_kot_notification.py):
    • Added TestOrderDelayNotification class testing rejection of non-existent KOTs, permission enforcement for unauthorized users, correct notification generation for authorized users, and skipping notifications when order status is not Ready For Prepare.

Previously any authenticated user could call the whitelisted
order_delay_notification endpoint with an arbitrary URY KOT id and
spam manager Notification Logs. The endpoint now verifies the KOT
exists and that the caller has read permission on that KOT document
(limited to System Manager / URY Manager / URY Captain / URY Cashier
roles) before creating any Notification Log entries.

Also guards against a missing invoice reference when building the
notification subject, and adds regression tests covering rejection of
nonexistent KOTs, rejection of unauthorized users, and the legitimate
delayed-KOT notification flow.
@esafwan esafwan changed the title Restrict order_delay_notification so arbitrary authenticated users can fix: restrict order_delay_notification so arbitrary authenticated users can Jul 21, 2026
@esafwan esafwan changed the title fix: restrict order_delay_notification so arbitrary authenticated users can fix: restrict order_delay_notification to authorized users with KOT read permissions Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant