gems httparty 0.25.1
v0.25.1

51 minutes ago

Full Changelog: v0.25.0...v0.25.1

This release stops credentials and cookies from following redirects to another site. Upgrading is recommended.

Security

Credentials no longer follow redirects to another origin

An Authorization header, basic_auth and digest_auth are now only sent to the same scheme, host and port they were given for, as in curl, Python requests and browsers. An http → https upgrade on the default ports keeps them. (#819, #915, thanks @davefej)

Before, credentials could reach another server in these cases:

Redirect Authorization in headers: basic_auth
To a different host sent dropped
Scheme-relative (//other.example.com/x) sent sent
https:// → http:// on the same host sent unencrypted sent unencrypted
Same host, different port sent sent

digest_auth also answered a 401 challenge from the host it was redirected to. All of these now drop the credentials. A redirect on the same host, or an http → https upgrade, still sends them.

Cookies no longer follow redirects to another origin

Cookies from headers:, the cookies: option, class-level cookies and the previous host's Set-Cookie were sent to any host a redirect pointed at. HTTParty doesn't track the cookie Domain attribute, so on a redirect to a different scheme, host or port it now sends none of them. Cookies the new host sets are kept for its own later redirects. (#916)

If a single request relies on a Domain=.example.com cookie reaching a sibling subdomain through a redirect (say login.example.com → app.example.com), that cookie is no longer sent.

Log lines can't be forged through the request path

ApacheFormatter escapes control characters, " and \ in the request path as Apache's own access log does (\x0d\x0a), so a crafted path can't split or forge a log line. This only applies with a permissive URI adapter such as Addressable; the default adapter already rejects these characters. (#892, #914, thanks @fuzzyrichie)

Bug Fixes

  • Cookies set by a same-origin redirect are sent along with your class and request cookies. Before, they replaced them, which could drop a session cookie on an ordinary redirect. (#916)
  • When a redirect turns a request into a GET, HTTParty no longer sends the headers that described the dropped body (Content-Type, Content-Length, Content-Encoding, Content-Language, Content-Location). (#696, #867, thanks @wleeaf)
  • A body_stream is dropped along with the body when a redirect turns the request into a GET. Before, the GET resent the already-read stream, which raised ArgumentError or went out chunked. (#917)
  • The curl log format no longer raises on UTF-16 or UTF-7 bodies, or on a non-ASCII header or query key with a binary value. (#848, #850, thanks @ethanstoner)
  • Responses declaring a Ruby "dummy" charset (UTF-7, UTF-32, ISO-2022-JP, IBM037) parse instead of raising Encoding::CompatibilityError. (#912)

Other

  • Gems built on Linux no longer include the spec and feature files. (#911)
  • Fixed four documentation examples that raised when run. (#913)
  • Added a cucumber scenario for relative redirects. (#918)

Don't miss a new httparty release

NewReleases is sending notifications on new releases.