Skip to content

Conversation

@adrien-k
Copy link
Contributor

@adrien-k adrien-k commented Apr 26, 2021

This can lead to a serious security issue if used as advised in the README

You can also set any specific HTTP header using the same way. As mentioned above, headers are thread-safe, so you can set headers dynamically, even in a multi-threaded environment:

ActiveResource::Base.headers['Authorization'] = current_session_api_token

If we consider this simple model:

ApiModel < ActiveResource::Base
  self.site = "http://api.some-site.com"
end

And the following sequence:

ActiveResource::Base.headers['Authorization'] = "Bob's TOKEN"
# Request made in Bob's name
ApiModel.find(1) 

ActiveResource::Base.headers['Authorization'] = "Alice's TOKEN"
# The request is still made with Bob's credentials, as ApiMode did read the header and kept a stale copy of it!!!
ApiModel.find(1) 

The fix should be compatible with the thread-safe attribute, although the code may need a second look.

@adrien-k adrien-k force-pushed the fix-headers-inheritance branch from 48cc3de to c0174ee Compare April 26, 2021 09:57
@adrien-k adrien-k force-pushed the fix-headers-inheritance branch 2 times, most recently from d763924 to cc0bdc8 Compare April 26, 2021 16:40
@adrien-k adrien-k force-pushed the fix-headers-inheritance branch from cc0bdc8 to 0f41a56 Compare April 26, 2021 16:49
@rails-bot
Copy link

rails-bot bot commented Jul 25, 2021

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

@rails-bot rails-bot bot added stale and removed stale labels Jul 25, 2021
@rails-bot
Copy link

rails-bot bot commented Oct 27, 2021

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

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 this pull request may close these issues.

1 participant