Skip to content

Form-encoded requests containing the word "payload" are parsed as an empty body #1628

Backlog

Description

@omkarbandikatte

A form-encoded request whose body contains the text payload anywhere, but has no payload parameter, is parsed as an empty body. For a slash command such as /deploy show payload size, request.body is {}, no app.command() listener matches, and the app responds with a 404 instead of running the handler.

parse_body in slack_bolt/request/internals.py checks "payload" in body on the raw body to tell interactivity requests (payload=<json>) from other form bodies. When the substring is there but the payload parameter is not, it returns {} instead of the form parameters it has already parsed:

if "payload" in body:  # This is not JSON format yet
    params = dict(parse_qsl(body, keep_blank_values=True))
    payload = params.get("payload")
    if payload is not None:
        return json.loads(payload)
    else:
        return {}

Any form field can carry the word: the command text, a channel name, a user name. The same code is in every release I checked back to v1.0.0.

Reproducible in:

The slack_bolt version

slack_bolt==1.30.0
slack_sdk==3.48.0

Also on main at 16056a4; slack_bolt/request/internals.py is unchanged between v1.30.0 and main.

Python runtime version

Python 3.13.18

OS info

macOS 26.6.2

Steps to reproduce:

  1. Save this as repro.py; it only parses a request and does not call any Slack API:

    from slack_bolt.request import BoltRequest
    
    headers = {"content-type": ["application/x-www-form-urlencoded"]}
    for text in ["show+size", "show+payload+size"]:
        body = f"command=%2Fdeploy&text={text}&team_id=T111&user_id=W111&trigger_id=111.111.xxx"
        print(f"text={text!r:22} -> {BoltRequest(body=body, headers=headers).body}")
  2. Run python repro.py.

Expected result:

The second body is parsed like the first, with 'text': 'show payload size', and the /deploy handler runs.

Actual result:

text='show+size'            -> {'command': '/deploy', 'text': 'show size', 'team_id': 'T111', 'user_id': 'W111', 'trigger_id': '111.111.xxx'}
text='show+payload+size'    -> {}

Dispatched to an App with an app.command() listener for that command, the same signed request returns a 404 and the listener is not called, because the empty body matches no listener. This affects AsyncApp too, since AsyncBoltRequest uses the same parse_body.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:asyncarea:syncbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions