Skip to content

delay: reject requests that did not come from the Task Queue service - #419

Open
Usamak06 wants to merge 1 commit into
golang:masterfrom
Usamak06:delay-require-queue-header
Open

Usamak06 wants to merge 1 commit into
golang:masterfrom
Usamak06:delay-require-queue-header

Conversation

@Usamak06

Copy link
Copy Markdown

Reproducer, POSTing a registered function's payload without any task queue headers:

--- FAIL: TestRunFuncRequiresQueueHeader (0.00s)
    delay_test.go:642: regFuncRuns: got 1, want 0
    delay_test.go:645: response code: got 200, want 403

runFunc gob-decodes the body of any request to /_ah/queue/go/delay and calls the registered function it names with the decoded arguments. The package doc allows that path to have no access restriction in app.yaml, so on such an app anyone can invoke any delay.Func with arguments of their choosing. App Engine strips X-AppEngine-* headers from external requests, so the handler now requires X-AppEngine-QueueName and returns 403 otherwise, the same check the Python deferred handler does with X-AppEngine-TaskName. Applied to both modules; existing tests now send the header.

runFunc, the handler for /_ah/queue/go/delay, gob-decodes the request
body and calls whichever registered function it names with the decoded
arguments. Nothing checks that the request was dispatched by the Task
Queue service, and the package documentation explicitly allows the path
to have no access restriction in app.yaml. On such an app any external
client can POST a forged invocation and run any delay.Func with
arguments of its choosing.

App Engine strips X-AppEngine-* headers from requests that come from
outside, so require X-AppEngine-QueueName and answer 403 without
decoding the body when it is missing. The Python deferred handler makes
the same check on X-AppEngine-TaskName.

Update the existing tests to send the header the Task Queue service
sets, and add a test that a request without it does not run the
function.
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