Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ gem '3scale_client', '~> 2.11', require: false
gem 'analytics-ruby', require: false

gem 'dalli'
gem 'faraday', '~> 2.0', '<= 2.9'
gem 'faraday', '~> 2.0', '>= 2.14.3'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we limit range to 2.x?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The ~> 2.0 constraint already limits to 2.x (it's equivalent to ">= 2.0, < 3.0"). So faraday '~> 2.0', '>= 2.14.3' means any 2.x version starting from 2.14.3.

gem 'mimemagic', '~> 0.3.10'
gem 'nokogiri', '~> 1.18.9', force_ruby_platform: true
gem 'secure_headers', '~> 6.3.0'
Expand Down
14 changes: 14 additions & 0 deletions THREESCALE-15318-pisoni-update.patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file seems to be totally useless here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, removed it.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/pisoni.gemspec b/pisoni.gemspec
index 4f62346..fc89442 100644
--- a/pisoni.gemspec
+++ b/pisoni.gemspec
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
s.license = 'Apache-2.0'

# faraday v2.9.0 removes support for Ruby 2.7, see https://github.com/lostisland/faraday/releases/tag/v2.9.0
- s.add_runtime_dependency 'faraday', '~> 2.0', '<= 2.9'
+ # Updated to allow Faraday 2.14.3+ which fixes nested query string vulnerability
+ s.add_runtime_dependency 'faraday', '~> 2.0', '>= 2.14.3'
s.add_runtime_dependency 'json', '~> 2.7', '>= 2.7.1'
s.add_runtime_dependency 'injectedlogger', '0.0.13'
s.add_runtime_dependency 'faraday-net_http_persistent', '~> 2.1'
52 changes: 52 additions & 0 deletions test/unit/faraday_nested_params_test.rb

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a good test to make sure the updated faraday works as advertised. But maybe no need to add tests for gems in our project

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! I can remove the test if you prefer.

The test serves two purposes:

  1. Regression prevention: Ensures we don't accidentally downgrade to a vulnerable Faraday version in the future
  2. Documentation: Shows why we have the >= 2.14.3 constraint (without mentioning CVEs in code)

However, you're right that testing gem behavior isn't really our responsibility - we trust the gem's own tests. Would you prefer I remove it and just rely on the Gemfile constraint?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes, remove the test file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

require 'test_helper'

class FaradayNestedParamsTest < ActiveSupport::TestCase
test 'Faraday handles deeply nested query parameters without stack overflow' do
# THREESCALE-15318: Test protection against CVE-2026-54297
# Faraday versions before 1.10.6 and 2.14.3 are vulnerable to DoS
# via crafted nested query strings that cause SystemStackError

# Create a deeply nested query string that would trigger the vulnerability
# in vulnerable Faraday versions
nested_depth = 100
nested_params = 'a' * nested_depth + '=1'
nested_depth.times { |i| nested_params = "a[#{nested_params}]" }

connection = Faraday.new(url: 'http://example.com') do |faraday|
faraday.adapter :test do |stub|
stub.get('/test') { |env| [200, {}, 'OK'] }
end
end

# This should not raise SystemStackError in patched versions
assert_nothing_raised do
# Try to make a request with deeply nested parameters
# The fix should handle this gracefully
connection.get('/test', {deep: nested_params})
end
rescue Faraday::ParamPart::PartLimitError
# This is expected in newer versions that enforce limits
# This means the fix is working
assert true
end

test 'oauth2 gem can handle complex query parameters' do
# THREESCALE-15318: Ensure oauth2 gem works correctly with the updated Faraday
# oauth2 gem uses Faraday internally, so we need to ensure compatibility

authentication_provider = FactoryBot.build_stubbed(:authentication_provider)
authentication = ThreeScale::OAuth2::Client.build_authentication(authentication_provider)

# This should work without errors
assert_nothing_raised do
client = ::OAuth2::Client.new(
authentication.client_id,
authentication.client_secret,
site: 'https://example.com'
)
assert client
end
end
end