Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Record credit failures #2620

Merged
merged 7 commits into from
Aug 12, 2014
Merged

Record credit failures #2620

merged 7 commits into from
Aug 12, 2014

Conversation

Changaco
Copy link
Contributor

@Changaco Changaco commented Aug 7, 2014

Another step of #2508. Fixes #1811. Built on top of #2579.

@Changaco
Copy link
Contributor Author

Rebased.

@chadwhitacre
Copy link
Contributor

Roger that. Waiting for Travis ...

@chadwhitacre
Copy link
Contributor

Sorry, thought I was looking at #2610. I was waiting for Travis on #2610.

@@ -87,15 +87,14 @@ def inbound(request):
"""Given a Request object, reject it if it's a forgery.
"""
if request.line.uri.startswith('/assets/'): return
if request.line.uri == '/balanced-callbacks': return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me nervous. No way around this?

Also, how about /callbacks/balanced instead? Seems not unlikely that we'll have additional callbacks in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me nervous.

Why? There's no need for a CSRF check there.

No way around this?

The docs say that callbacks can be sent as GET requests, which would slip through the CSRF check, but I'm not sure how that's any better.

Also, how about /callbacks/balanced instead?

Good idea.

@Changaco
Copy link
Contributor Author

Move done. (/balanced-callbacks.spt/callbacks/balanced.spt)

raise Response(405)

src = request.headers['X-Forwarded-For']
if not src in ('50.18.199.26', '50.18.204.103'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the behavior at Heroku if a client sends X-Forwarded-For? Do they replace it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I expect, the documentation doesn't say.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test that. If they don't handle X-Forwarded-For properly then a client could trivially bypass this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tested this: the values of X-Forwarded-For form a chain, they're joined with commas. Bottom line: we're good, our check still works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. How hard is it to spoof an IP address otherwise? It seems like an IP filter is really weak security for this endpoint, but it looks like that's the best they give us.

As an added safety precaution to ensure event validity, you may also manually fetch the changed entity resource and compare it with records in your system before processing any changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mean time, we should implement the workaround, which is to perform an additional API request to load the relevant resource and confirm the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard is it to spoof an IP address otherwise?

Spoofing an IP address is not too difficult, but the connections we're receiving are HTTP, which is based on TCP, which uses a three-way handshake, so if you spoof the source address you can't establish the connection, unless you're an active MITM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we're not worried about MITM because Balanced isn't hitting us from a coffee shop, and anyway they're hitting us over SSL. Right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I turned off the callback in #2631 and then turned it back on in #2632 because of this IRC conversation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we're not worried about MITM because Balanced isn't hitting us from a coffee shop, and anyway they're hitting us over SSL. Right?

Yes, except SSL doesn't really help us in this case.

chadwhitacre added a commit that referenced this pull request Aug 12, 2014
@chadwhitacre chadwhitacre merged commit d986e98 into payday-rewrite-5 Aug 12, 2014
@chadwhitacre chadwhitacre deleted the record-ach-failures branch August 12, 2014 18:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants