You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Check message bytesize before Base64 validation
* Adapt tests to be able to execute signature validation sooner
* CI/CD: Update ubuntu version
* Add Ruby 3.4 to the CI
* Exclude Ubuntu-22.04 Ruby 2.2 from CI as it raises RubyGem/Bundler issues
* Release 1.18.1
* Update Changelog
* Fix several typos on the documentation and code. Add to the README how to force SP-Initiate flow and Prevent Reply Attacks
* Improve the inflate method to prevent potential DoS vulnerability in Zlib::Inflate (SAML-Toolkits#779)
Improve the inflate method. Prevent potential DoS vulnerability in Zlib::Inflate by limiting the maximum decompressed size. The data is now inflated in chunks.
* Add sponsors: Github, SerpApi
* Add warning about CVE-2025-66567 and CVE-2025-66568CVE-2025-66567 and CVE-2025-66568 affects ruby-saml <= 1.12.4. Use ruby-saml 1.18.1 instead.
* Revise vulnerability notice for ruby-saml
Updated vulnerability notice to reflect affected versions.
* Fix wrong link
---------
Co-authored-by: Drew Blessing <drew@blessing.io>
Co-authored-by: Sixto Martin <sixto.martin.garcia@workato.com>
Co-authored-by: Sixto Martin <sixto.martin.garcia@gmail.com>
Co-authored-by: Sixto Martin <pitbulk@gmail.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,10 @@
1
1
# Ruby SAML Changelog
2
2
3
+
### 1.18.1 (Jul 29, 2025)
4
+
* Fix vulnerability CVE-2025-54572 Prevent DOS due large SAML Message
5
+
* Adapt tests to be able to execute signature validation sooner
6
+
* CI Improvements. Support Ruby 3.4
7
+
3
8
### 1.18.0 (Mar 12, 2025)
4
9
*[#750](https://github.com/SAML-Toolkits/ruby-saml/pull/750) Fix vulnerabilities: CVE-2025-25291, CVE-2025-25292: SAML authentication bypass via Signature Wrapping attack allowed due parser differential. Fix vulnerability: CVE-2025-25293: Potential DOS abusing of compressed messages.
5
10
*[#718](https://github.com/SAML-Toolkits/ruby-saml/pull/718/) Add support to retrieve from SAMLResponse the AuthnInstant and AuthnContextClassRef values
Minor and patch versions of Ruby SAML may introduce breaking changes. Please read
8
8
[UPGRADING.md](UPGRADING.md) for guidance on upgrading to new Ruby SAML versions.
9
9
10
-
### Pay it Forward: Support RubySAML and Strengthen Open-Source Security
11
10
12
-
RubySAML is a trusted authentication library used by startups and enterprises alike.
11
+
## Vulnerability Notice
13
12
14
-
But security doesn't happen in a vacuum. Vulnerabilities in authentication libraries can
15
-
have widespread consequences. Maintaining open-source security requires continuous
16
-
effort, expertise, and funding. By supporting RubySAML, you’re not just securing your
17
-
own systems—you’re strengthening auth security globally.
13
+
[CVE-2025-66568](https://github.com/SAML-Toolkits/ruby-saml/security/advisories/GHSA-x4h9-gwv3-r4m4) and [CVE-2025-66567](https://github.com/SAML-Toolkits/ruby-saml/security/advisories/GHSA-9v8j-x534-2fx3). affects version ruby-saml < 1.18.0 (including 1.12.4), upgrade to 1.18.1
* Responsibly report vulnerabilities (see "Vulnerability Reporting" above)
17
+
There are critical vulnerabilities affecting ruby-saml < 1.18.0, two of them allows SAML authentication bypass (CVE-2025-25291, CVE-2025-25292, CVE-2025-25293). Please upgrade to a fixed version (1.18.0)
24
18
25
-
Security is a shared responsibility. If RubySAML has helped your organization, please
26
-
consider giving back. Together, we can keep authentication secure.
19
+
### Vulnerability Reporting
27
20
28
-
### Sponsors
21
+
If you believe you have discovered a security vulnerability in this gem, please report
22
+
it by email to the maintainer: sixto.martin.garcia+security@gmail.com
29
23
30
-
Thanks to the following sponsors for securing the open source ecosystem,
<sup>*A real-time API to access Google search results. It handle proxies, solve captchas, and parse all rich structured data for you*</sup>
36
31
37
-
There are critical vulnerabilities affecting ruby-saml < 1.18.0, two of them allows SAML authentication bypass (CVE-2025-25291, CVE-2025-25292, CVE-2025-25293). Please upgrade to a fixed version (1.18.0)
The following Ruby versions are covered by CI testing:
50
+
### Security Considerations
53
51
54
-
* Ruby (MRI) 2.1 to 3.3
55
-
* JRuby 9.1 to 9.4
56
-
* TruffleRuby (latest)
57
-
58
-
## Adding Features, Pull Requests
59
-
60
-
* Fork the repository
61
-
* Make your feature addition or bug fix
62
-
* Add tests for your new features. This is important so we don't break any features in a future version unintentionally.
63
-
* Ensure all tests pass by running `bundle exec rake test`.
64
-
* Do not change Rakefile, version, or history.
65
-
* Open a pull request, following [this template](https://gist.github.com/Lordnibbler/11002759).
66
-
67
-
## Security Guidelines
52
+
-**Validation of the IdP Metadata URL:** When loading IdP Metadata from a URLs,
53
+
Ruby SAML requires you (the developer/administrator) to ensure the supplied URL is correct
54
+
and from a trusted source. Ruby SAML does not perform any validation that the URL
55
+
you entered is correct and/or safe.
56
+
-**False-Positive Security Warnings:** Some tools may incorrectly report Ruby SAML as a
57
+
potential security vulnerability, due to its dependency on Nokogiri. Such warnings can
58
+
be ignored; Ruby SAML uses Nokogiri in a safe way, by always disabling its DTDLOAD option
59
+
and enabling its NONET option.
60
+
-**Prevent Replay attacks:** A replay attack is when an attacker intercepts a valid SAML
61
+
assertion and "replays" it at a later time to gain unauthorized access. The `ruby-saml`
62
+
library provides the tools to prevent this, but **you, the developer, must implement thecore logic**, see an specific section later in the README.
68
63
69
-
If you believe you have discovered a security vulnerability in this gem, please report it
70
-
by mail to the maintainer: sixto.martin.garcia+security@gmail.com
71
64
72
-
### Security Warning
73
-
74
-
Some tools may incorrectly report ruby-saml is a potential security vulnerability.
75
-
ruby-saml depends on Nokogiri, and it is possible to use Nokogiri in a dangerous way
76
-
(by enabling its DTDLOAD option and disabling its NONET option).
77
-
This dangerous Nokogiri configuration, which is sometimes used by other components,
78
-
can create an XML External Entity (XXE) vulnerability if the XML data is not trusted.
79
-
However, ruby-saml never enables this dangerous Nokogiri configuration;
80
-
ruby-saml never enables DTDLOAD, and it never disables NONET.
65
+
### Supported Ruby Versions
81
66
82
-
The OneLogin::RubySaml::IdpMetadataParser class does not validate the provided URL before parsing.
67
+
The following Ruby versions are covered by CI testing:
83
68
84
-
Usually, the same administrator who handles the Service Provider also sets the URL to
85
-
the IdP, which should be a trusted resource.
69
+
* Ruby (MRI) 2.1 to 3.4
70
+
* JRuby 9.1 to 9.4
71
+
* TruffleRuby (latest)
86
72
87
-
But there are other scenarios, like a SaaS app where the administrator of the app
88
-
delegates this functionality to other users. In this case, extra precautions should
89
-
be taken in order to validate such URL inputs and avoid attacks like SSRF.
90
73
91
74
## Getting Started
92
75
@@ -429,8 +412,8 @@ Those return an Hash instead of a `Settings` object, which may be useful for con
429
412
430
413
### Validating Signature of Metadata and retrieve settings
431
414
432
-
Right now there is no method at ruby_saml to validate the signature of the metadata that gonna be parsed,
433
-
but it can be done as follows:
415
+
Right now there is no method at ruby_saml to validate the signature of the metadata that is going to be parsed, but it can be done as follows:
416
+
434
417
* Download the XML.
435
418
* Validate the Signature, providing the cert.
436
419
* Provide the XML to the parse method if the signature was validated
@@ -719,7 +702,7 @@ SP Metadata XML, to be read by the IdP.
719
702
#### Verifying Signature on IdP Assertions
720
703
721
704
You may require the IdP to sign its SAML Assertions using the following setting.
722
-
With will add `<md:SPSSODescriptor WantAssertionsSigned="true">` to your SP Metadata XML.
705
+
This will add `<md:SPSSODescriptor WantAssertionsSigned="true">` to your SP Metadata XML.
723
706
The signature will be checked against the `<md:KeyDescriptor use="signing">` element
724
707
present in the IdP's metadata.
725
708
@@ -751,7 +734,7 @@ advanced usage scenarios:
751
734
- Specifying separate SP certificates for signing and encryption.
752
735
753
736
The `sp_cert_multi` parameter replaces `certificate` and `private_key`
754
-
(you may not specify both pparameters at the same time.) `sp_cert_multi` has the following shape:
737
+
(you may not specify both parameters at the same time.) `sp_cert_multi` has the following shape:
755
738
756
739
```ruby
757
740
settings.sp_cert_multi = {
@@ -821,7 +804,7 @@ def sp_logout_request
821
804
settings = saml_settings
822
805
823
806
if settings.idp_slo_service_url.nil?
824
-
logger.info "SLO IdP Endpoint not found in settings, executing then a normal logout'"
807
+
logger.info "SLO IdP Endpoint not found in settings, then executing a normal logout'"
825
808
delete_session
826
809
else
827
810
@@ -1004,3 +987,158 @@ end
1004
987
# Output XML with custom metadata
1005
988
MyMetadata.new.generate(settings)
1006
989
```
990
+
991
+
### Preventing Replay Attacks
992
+
993
+
A replay attack is when an attacker intercepts a valid SAML assertion and "replays" it at a later time to gain unauthorized access.
994
+
995
+
The library only checks the assertion's validity window (`NotBefore` and `NotOnOrAfter` conditions). An attacker can replay a valid assertion as many times as they want within this window.
996
+
997
+
A robust defense requires tracking of assertion IDs to ensure any given assertion is only accepted once.
998
+
999
+
#### 1. Extract the Assertion ID after Validation
1000
+
1001
+
After a response has been successfully validated, get the assertion ID. The library makes this available via `response.assertion_id`.
1002
+
1003
+
1004
+
#### 2. Store the ID with an Expiry
1005
+
1006
+
You must store this ID in a persistent cache (like Redis or Memcached) that is shared across your servers. Do not store it in the user's session, as that is not a secure cache.
1007
+
1008
+
The ID should be stored until the assertion's validity window has passed. You will need to check how long the trusted IdPs consider the assertion valid and then add the allowed_clock_drift.
1009
+
1010
+
You can define a global value, or set this value dinamically based on the `not_on_or_after` value of the re + `allowed_clock_drift`.
1011
+
1012
+
```ruby
1013
+
# In your `consume` action, after a successful validation:
1014
+
if response.is_valid?
1015
+
# Prevent replay of this specific assertion
1016
+
assertion_id = response.assertion_id
1017
+
authorize_failure("Assertion ID is mandatory") if assertion_id.nil?
### Enforce SP-Initiated Flow with `InResponseTo` validation
1055
+
1056
+
This is the best way to prevent IdP-initiated logins and ensure that you only accept assertions that you recently requested.
1057
+
1058
+
#### 1. Store the `AuthnRequest` ID
1059
+
1060
+
When you create an `AuthnRequest`, the library assigns it a unique ID. You must store this ID, forexamplein the user's session *before* redirecting them to the IdP.
1061
+
1062
+
```ruby
1063
+
def init
1064
+
request = OneLogin::RubySaml::Authrequest.new
1065
+
# The unique ID of the request is in request.uuid
1066
+
session[:saml_request_id] = request.uuid
1067
+
redirect_to(request.create(saml_settings))
1068
+
end
1069
+
```
1070
+
1071
+
#### 2. Validate the `InResponseTo` value of the `Response` with the Stored ID
1072
+
1073
+
When you process the `SAMLResponse`, retrieve the ID from the session and pass it to the `Response` constructor. Use `session.delete` to ensure the ID can only be used once.
1074
+
1075
+
```ruby
1076
+
def consume
1077
+
request_id = session.delete(:saml_request_id) # Use delete to prevent re-use
1078
+
1079
+
# You can reject the response if no previous saml_request_id was stored
1080
+
raise "IdP-initiaited detected" if request_id.nil?
1081
+
1082
+
response = OneLogin::RubySaml::Response.new(
1083
+
params[:SAMLResponse],
1084
+
settings: saml_settings,
1085
+
matches_request_id: request_id
1086
+
)
1087
+
1088
+
if response.is_valid?
1089
+
# ... authorize user
1090
+
else
1091
+
# Response is invalid, errors in response.errors
1092
+
end
1093
+
end
1094
+
```
1095
+
1096
+
## Contributing
1097
+
1098
+
### Pay it Forward: Support RubySAML and Strengthen Open-Source Security
1099
+
1100
+
RubySAML is a trusted authentication library used by startups and enterprises alike—
1101
+
a community-driven alternative to costly third-party services.
1102
+
1103
+
But security doesn't happen in a vacuum. Vulnerabilities in authentication libraries can
1104
+
have widespread consequences. Maintaining open-source security requires continuous
1105
+
effort, expertise, and funding. By supporting RubySAML, you’re not just securing your
1106
+
own systems—you’re strengthening auth security globally. Instead of paying for closed
1107
+
solutions, consider investing in the community that does the real security work.
Copy file name to clipboardExpand all lines: UPGRADING.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ how validation happens in the toolkit and also the toolkit by default will check
7
7
when parsing a SAML Message (`settings.check_malformed_doc`).
8
8
9
9
The SignedDocument class defined at xml_security.rb experienced several changes.
10
-
We don't expect compatibilty issues if you use the main methods offered by ruby-saml, but if you use a fork or customized usage, is possible that you need to adapt your code.
10
+
We don't expect compatibility issues if you use the main methods offered by ruby-saml, but if you use a fork or customized usage, is possible that you need to adapt your code.
11
11
12
12
## Updating from 1.12.x to 1.13.0
13
13
@@ -33,7 +33,7 @@ in favor of `idp_sso_service_url` and `idp_slo_service_url`. The `IdpMetadataPar
33
33
34
34
## Upgrading from 1.10.x to 1.11.0
35
35
36
-
Version `1.11.0` deprecates the use of `settings.issuer` in favour of `settings.sp_entity_id`.
36
+
Version `1.11.0` deprecates the use of `settings.issuer` in favor of `settings.sp_entity_id`.
37
37
There are two new security settings: `settings.security[:check_idp_cert_expiration]` and
38
38
`settings.security[:check_sp_cert_expiration]` (both false by default) that check if the
39
39
IdP or SP X.509 certificate has expired, respectively.
@@ -44,7 +44,7 @@ Version `1.10.1` improves Ruby 1.8.7 support.
44
44
45
45
## Upgrading from 1.9.0 to 1.10.0
46
46
47
-
Version `1.10.0` improves IdpMetadataParser to allow parse multiple IDPSSODescriptor,
47
+
Version `1.10.0` improves IdpMetadataParser to allow parsing multiple IDPSSODescriptor,
48
48
Add Subject support on AuthNRequest to allow SPs provide info to the IdP about the user
49
49
to be authenticated and updates the format_cert method to accept certs with /\x0d/
50
50
@@ -128,7 +128,7 @@ It adds security improvements in order to prevent Signature wrapping attacks.
128
128
129
129
## Upgrading from 1.1.x to 1.2.x
130
130
131
-
Version `1.2` adds IDP metadata parsing improvements, uuid deprecation in favour of SecureRandom,
131
+
Version `1.2` adds IDP metadata parsing improvements, uuid deprecation in favor of SecureRandom,
132
132
refactor error handling and some minor improvements.
133
133
134
134
There is no compatibility issue detected.
@@ -143,7 +143,7 @@ Version `1.1` adds some improvements on signature validation and solves some nam
143
143
144
144
Version `1.0` is a recommended update for all Ruby SAML users as it includes security fixes.
145
145
146
-
Version `1.0` adds security improvements like entity expansion limitation, more SAML message validations, and other important improvements like decrypt support.
146
+
Version `1.0` adds security improvements like entity expansion limitation, more SAML message validations, and other important improvements like decryption support.
0 commit comments