Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrimStrings middleware breaks signature verification #120

Closed
mpociot opened this issue May 27, 2021 · 6 comments · Fixed by #121
Closed

TrimStrings middleware breaks signature verification #120

mpociot opened this issue May 27, 2021 · 6 comments · Fixed by #121
Labels

Comments

@mpociot
Copy link

mpociot commented May 27, 2021

  • Cashier Paddle Version: 1.4.4
  • Laravel Version: 8.43.0
  • PHP Version: 8.0.5

Description:

When a user enters any data with a leading/trailing whitespace, the signature verification is broken, because the TrimStrings middleware removed the whitespace, while the provided signature expects the whitespace.

Steps To Reproduce:

Perform a Paddle request with a leading/trailing whitespace.

@driesvints
Copy link
Member

Can you give a specific example of how to do this?

@mpociot
Copy link
Author

mpociot commented May 27, 2021

It happened to me when having a whitespace in a passthrough parameter, but I think if you have whitespace in your name, it should happen too

@driesvints
Copy link
Member

@mpociot I'll take a look tomorrow 👍

@driesvints
Copy link
Member

This all works for me:

Auth::user()->charge(12.55, 'Test Charge', ['passthrough' => ['test' => ' Test with space ']]);

Screenshot 2021-05-28 at 10 51 54

I tried also to set the name on the card with a leading and trailing space. Funny thing is that Paddle marked the name as invalid when I have a leading space but it doesn't when I have a trailing space. In any case, the trailing space also didn't cause the signature to be broken. I'll need more specific steps to reproduce this.

Screenshot 2021-05-28 at 10 47 30

@mpociot
Copy link
Author

mpociot commented May 28, 2021

Okay, then this only happens with a passthrough that contains a leading space:

Auth::user()->charge(12.55, 'Test Charge', ['passthrough' => '    Uh Oh']);

@driesvints
Copy link
Member

That's not possible. You should get an exception for that. It's not possible to do a charge like that. The passthrough should always be an array. Are you overwriting this somehow?

if (! is_array($payload['passthrough'])) {
throw new LogicException('The value for "passthrough" always needs to be an array.');
}

@driesvints driesvints reopened this May 28, 2021
patrickomeara added a commit to patrickomeara/cashier-paddle that referenced this issue Aug 7, 2024
Paddle verifies the signature based on the input as they have it on their end. If Cashier receives strings that have been trimmed the signature verification fails. The fields need to stay as they are.

laravel#120
laravel#152
laravel#173
taylorotwell pushed a commit that referenced this issue Aug 8, 2024
Paddle verifies the signature based on the input as they have it on their end. If Cashier receives strings that have been trimmed the signature verification fails. The fields need to stay as they are.

#120
#152
#173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants