MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challenge
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 68/100
Piste de recherche
Commencez dans bedrock_agentcore/payments/manager.py, au niveau de PaymentManager._generate_mpp_payment_header, et suivez le cheminement de l’en-tête de défi sélectionné jusqu’à generate_payment_header. Vérifiez comment le gestionnaire Strands et le middleware LangGraph appliquent les en-têtes renvoyés, puis ajoutez ou exécutez des tests ciblés pour Payment-Authorization et le comportement par défaut de Authorization. La tâche est terminée lorsque l’en-tête sélectionné contient l’identifiant d’authentification et que la valeur Authorization existante de l’appelant est préservée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
The MPP core spec lets a challenge choose the request header for the credential. With header="Payment-Authorization", the client must send the credential in Payment-Authorization, so that Authorization stays free for the client's own authentication (draft-httpauth-payment-01, section "Credentials"). The server accepts the credential only from the selected field, and a client that does not support Payment-Authorization must not send a credential for such a challenge.
PaymentManager._generate_mpp_payment_header always returns {"Authorization": "Payment <credential>"}, whatever the selected challenge says. For a challenge with header="Payment-Authorization", the SDK:
- pays it (
ProcessPaymentis called); - returns the credential under
Authorization, where the server does not look for it; - replaces the caller's own
Authorizationvalue (for example a Bearer token) when the Strands plugin or the LangGraph middleware applies the header to the retried request (apply_payment_headerupdates the headers dict).
mppx servers send this parameter when created with Mppx.create({ requiresAuth: true, ... }) (added in mppx 0.9.0), and then read the credential only from Payment-Authorization.
To Reproduce
bedrock-agentcore 1.24.1 (main at b70e0b7), Python 3.10:
import base64
import json
from unittest.mock import MagicMock, patch
from bedrock_agentcore.payments.integrations.handlers import GenericPaymentHandler
from bedrock_agentcore.payments.manager import PaymentManager
request = {
"amount": "1000",
"currency": "0x036CbD53842c5426634e7929541eC2318f3dCF71",
"recipient": "0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00",
"methodDetails": {"chainId": 84532},
}
encoded = base64.urlsafe_b64encode(json.dumps(request, separators=(",", ":")).encode()).decode().rstrip("=")
challenge = (
f'Payment id="x7Tg2pLqR9mKvNwY3hBcZa", realm="api.example.com", method="evm", intent="charge", '
f'header="Payment-Authorization", request="{encoded}"'
)
with patch("boto3.Session") as session:
session.return_value.region_name = "us-west-2"
manager = PaymentManager(
payment_manager_arn="arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/pm-abc123",
region_name="us-west-2",
)
manager._payment_client = MagicMock()
manager._payment_client.get_payment_instrument.return_value = {
"paymentInstrument": {"paymentInstrumentDetails": {"embeddedCryptoWallet": {"network": "ETHEREUM"}}}
}
manager._payment_client.process_payment.return_value = {
"processPayment": {
"status": "PROOF_GENERATED",
"paymentOutput": {"mpp": {"selectedPaymentId": "x7Tg2pLqR9mKvNwY3hBcZa", "paymentCredential": "eyJ0b2tlbiI6MX0"}},
}
}
payment_header = manager.generate_payment_header(
user_id="user-1",
payment_instrument_id="pi-1",
payment_session_id="ps-1",
payment_required_request={"statusCode": 402, "headers": {"WWW-Authenticate": challenge}, "body": {}},
)
print("ProcessPayment calls:", manager._payment_client.process_payment.call_count)
print("payment header:", payment_header)
tool_input = {"url": "https://api.example.com/resource", "headers": {"Authorization": "Bearer mF_9.B5f-4.1JqM"}}
GenericPaymentHandler().apply_payment_header(tool_input, payment_header)
print("retried request headers:", tool_input["headers"])
Output:
ProcessPayment calls: 1
payment header: {'Authorization': 'Payment eyJ0b2tlbiI6MX0'}
retried request headers: {'Authorization': 'Payment eyJ0b2tlbiI6MX0'}
Expected behavior
For a challenge with header="Payment-Authorization", generate_payment_header returns {"Payment-Authorization": "Payment <credential>"}, and the retried request keeps its own Authorization header. A challenge without header keeps using Authorization, as now. Until the field is supported, such a challenge should not be selected or paid.
Additional context
- The parameter was added to the spec in tempoxyz/mpp-specs#328 (2026-08-25), a week after MPP support landed here in #643 (2026-08-18).
- The spec also asks the client to echo
headerin the credential'schallengeobject. The raw challenge, includingheader, is already forwarded toProcessPayment, so that part may be handled by the service; I could not check it.
- Langage dominant
- Python
- Étoiles
- 786
- Forks
- 163
- Merge moyen
- 4 h
- PR mergées (30 j)
- 22
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de aws/bedrock-agentcore-sdk-python
-
bug high-severity
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Les mainteneurs répondent en général sous 1 jour
-
OpenAIConverseConverter restores an empty history when one blob or text payload fails to parseOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
delete_all_long_term_memories_in_namespace deletes only the first 10 recordsPeut-être pris @Fire162 l’a pris il y a 18 jours. Ouvertebug high-severity
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
aws/bedrock-agentcore-sdk-python#727 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexPeut-être pris @citizen204 l’a pris il y a 144 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Les mainteneurs répondent en général sous 1 jour
-
CodeInterpreter should not require a region argumentPeut-être pris @citizen204 l’a pris il y a 159 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
aws/bedrock-agentcore-sdk-python#511 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de aws/bedrock-agentcore-sdk-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
bug difficulty:2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
MakazhanAlpamys/Soup#3167 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
snap-stanford/Biomni#380 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
jsboige/CoursIA#27768 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
[Resource]: Math ParadoxesOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 66/100
rossant/awesome-math#206 ·