Skip to content

Commit 24c3934

Browse files
committed
Fix for CVE
1 parent fd5ad7e commit 24c3934

File tree

13 files changed

+292
-139
lines changed

13 files changed

+292
-139
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Metrics/BlockLength:
192192
# Offense count: 8
193193
# Configuration parameters: CountComments, CountAsOne.
194194
Metrics/ClassLength:
195-
Max: 661
195+
Max: 1000
196196

197197
# Offense count: 29
198198
# Configuration parameters: AllowedMethods, AllowedPatterns.

README.md

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Ruby SAML minor versions may introduce breaking changes. Please read
99

1010
## Vulnerability Notice
1111

12-
**There is a critical vulnerability affecting ruby-saml < 1.17.0 (CVE-2024-45409).
13-
Make sure you are using an updated version. (1.12.3 is safe)**
12+
There are **critical vulnerabilities** affecting ruby-saml < 1.18.0 which allow
13+
SAML authentication bypass (CVE-2024-45409, CVE-2025-25291, CVE-2025-25292, CVE-2025-25293).
14+
**Please upgrade to a fixed version (1.18.0 or 2.0.0) as soon as possible.**
1415

1516
## Overview
1617

@@ -589,7 +590,7 @@ settings.security[:digest_method] = RubySaml::XML::SHA1
589590
settings.security[:signature_method] = RubySaml::XML::RSA_SHA1
590591
```
591592

592-
#### Signing SP Metadata
593+
### Signing SP Metadata
593594

594595
You may add a `<ds:Signature>` digital signature element to your SP Metadata XML using the following setting:
595596

@@ -600,7 +601,7 @@ settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
600601
settings.security[:metadata_signed] = true # Enable signature on Metadata
601602
```
602603

603-
#### Signing SP SAML Messages
604+
### Signing SP SAML Messages
604605

605606
Ruby SAML supports SAML request signing. You (the SP) will sign the
606607
request/responses with your private key. The IdP will then validate the signature
@@ -627,7 +628,7 @@ Note that the RelayState parameter is used when creating the Signature on the `H
627628
Remember to provide it to the Signature builder if you are sending a `GET RelayState` parameter or the
628629
signature validation process will fail at the IdP.
629630

630-
#### Decrypting IdP SAML Assertions
631+
### Decrypting IdP SAML Assertions
631632

632633
Ruby SAML supports EncryptedAssertion. The IdP will encrypt the Assertion with the
633634
public cert of the SP. The SP will decrypt the EncryptedAssertion with its private key.
@@ -642,7 +643,7 @@ settings.private_key = "PRIVATE KEY TEXT WITH BEGIN/END HEADER AND FOOTER"
642643
settings.security[:want_assertions_encrypted] = true # Invalidate SAML messages without an EncryptedAssertion
643644
```
644645

645-
#### Verifying Signature on IdP Assertions
646+
### Verifying Signature on IdP Assertions
646647

647648
You may require the IdP to sign its SAML Assertions using the following setting.
648649
With will add `<md:SPSSODescriptor WantAssertionsSigned="true">` to your SP Metadata XML.
@@ -653,7 +654,7 @@ present in the IdP's metadata.
653654
settings.security[:want_assertions_signed] = true # Require the IdP to sign its SAML Assertions
654655
```
655656

656-
#### Certificate and Signature Validation
657+
### Certificate and Signature Validation
657658

658659
You may require SP and IdP certificates to be non-expired using the following settings:
659660

@@ -669,7 +670,7 @@ validation fails. You may disable such exceptions using the `settings.security[:
669670
settings.security[:soft] = true # Do not raise error on failed signature/certificate validations
670671
```
671672

672-
#### Advanced SP Certificate Usage & Key Rollover
673+
### Advanced SP Certificate Usage & Key Rollover
673674

674675
Ruby SAML provides the `settings.sp_cert_multi` parameter to enable the following
675676
advanced usage scenarios:
@@ -711,12 +712,12 @@ Note the following:
711712
inactive/expired certificates. This avoids validation errors when the IdP reads the SP
712713
metadata.
713714

714-
#### Key Algorithm Support
715+
### Key Algorithm Support
715716

716717
Ruby SAML supports RSA, DSA, and ECDSA keys for both SP and IdP certificates.
717718
JRuby cannot support ECDSA due to a [known issue](https://github.com/jruby/jruby-openssl/issues/257).
718719

719-
#### Audience Validation
720+
### Audience Validation
720721

721722
A service provider should only consider a SAML response valid if the IdP includes an <AudienceRestriction>
722723
element containting an <Audience> element that uniquely identifies the service provider. Unless you specify
@@ -739,7 +740,7 @@ is invalid using the `settings.security[:strict_audience_validation]` parameter.
739740
settings.security[:strict_audience_validation] = true
740741
```
741742

742-
## Single Log Out
743+
### Single Log Out
743744

744745
Ruby SAML supports SP-initiated Single Logout and IdP-Initiated Single Logout.
745746

@@ -860,7 +861,7 @@ def logout
860861
end
861862
```
862863

863-
## Clock Drift
864+
### Clock Drift
864865

865866
If during validation of the response you get the error "Current time is earlier than NotBefore condition",
866867
this may be due to clock differences between your system and that of the IdP.
@@ -877,7 +878,7 @@ response = RubySaml::Response.new(params[:SAMLResponse], allowed_clock_drift: 1.
877878

878879
Make sure to keep the value as comfortably small as possible to keep security risks to a minimum.
879880

880-
## Deflation Limit
881+
### Deflation Limit
881882

882883
To protect against decompression bombs (a form of DoS attack), SAML messages are limited to 250,000 bytes by default.
883884
Sometimes legitimate SAML messages will exceed this limit,
@@ -898,7 +899,7 @@ def saml_settings
898899
end
899900
```
900901

901-
## Attribute Service
902+
### Attribute Service
902903

903904
To request attributes from the IdP the SP needs to provide an attribute service within it's metadata and reference the index in the assertion.
904905

@@ -915,7 +916,7 @@ end
915916

916917
The `attribute_value` option additionally accepts an array of possible values.
917918

918-
## SP-Originated Message IDs
919+
### SP-Originated Message IDs
919920

920921
Ruby SAML automatically generates message IDs for SP-originated messages (AuthNRequest, etc.)
921922
By default, this is a UUID prefixed by the `_` character, for example `"_ea8b5fdf-0a71-4bef-9f87-5406ee746f5b"`.
@@ -924,7 +925,7 @@ Note that the SAML specification requires that this type (`xsd:ID`) be an
924925
[NCName](https://www.w3.org/TR/xmlschema-2/#NCName), meaning that it must start with a letter
925926
or underscore, and can only contain letters, digits, underscores, hyphens, and periods.
926927

927-
## Custom Metadata Fields
928+
### Custom Metadata Fields
928929

929930
Some IdPs may require to add SPs to add additional fields (Organization, ContactPerson, etc.)
930931
into the SP metadata. This can be achieved by extending the `RubySaml::Metadata`
@@ -948,7 +949,30 @@ end
948949
MyMetadata.new.generate(settings)
949950
```
950951

951-
## Adding Features, Pull Requests
952+
## Contributing
953+
954+
### Pay it Forward: Support RubySAML and Strengthen Open-Source Security
955+
956+
RubySAML is a trusted authentication library used by startups and enterprises alike—
957+
a community-driven alternative to costly third-party services.
958+
959+
But security doesn't happen in a vacuum. Vulnerabilities in authentication libraries can
960+
have widespread consequences. Maintaining open-source security requires continuous
961+
effort, expertise, and funding. By supporting RubySAML, you’re not just securing your
962+
own systems—you’re strengthening auth security globally. Instead of paying for closed
963+
solutions, consider investing in the community that does the real security work.
964+
965+
#### How you can help
966+
967+
* Sponsor RubySAML: [GitHub Sponsors](https://github.com/sponsors/SAML-Toolkits)
968+
* Contribute to secure-by-design improvements
969+
* Responsibly report vulnerabilities (see "Vulnerability Reporting" above)
970+
971+
Security is a shared responsibility. If RubySAML has helped your organization, please
972+
consider giving back. Together, we can keep authentication secure—without putting it
973+
behind paywalls.
974+
975+
### Adding Features, Pull Requests
952976

953977
* Fork the repository
954978
* Make your feature addition or bug fix
@@ -957,12 +981,18 @@ MyMetadata.new.generate(settings)
957981
* Do not change rakefile, version, or history.
958982
* Open a pull request, following [this template](https://gist.github.com/Lordnibbler/11002759).
959983

960-
## Attribution
984+
### Sponsors
985+
986+
Thanks to the following sponsors for securing the open source ecosystem.
987+
988+
[<img alt="84codes" src="https://avatars.githubusercontent.com/u/5353257" width="75px">](https://www.84codes.com)
989+
990+
### Attribution
961991

962992
Portions of the code in `RubySaml::XML` namespace is adapted from earlier work
963993
copyrighted by either Oracle and/or Todd W. Saxton. The original code was distributed
964-
under the Common Development and Distribution License (CDDL) 1.0. This code is planned to
965-
be written entirely in future versions.
994+
under the Common Development and Distribution License (CDDL) 1.0. This code is
995+
currently in the process of being rewritten.
966996

967997
## License
968998

UPGRADING.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ruby SAML Migration Guide
22

3-
## Updating from 1.17.x to 2.0.0
3+
## Updating from 1.x to 2.0.0
44

55
**IMPORTANT: Please read this section carefully as it contains breaking changes!**
66

@@ -32,8 +32,8 @@ as before. This alias will be removed in RubySaml version `2.1.0`.
3232

3333
### Root "XMLSecurity" namespace changed to "RubySaml::XML"
3434

35-
RubySaml version `2.0.0` changes the namespace `XMLSecurity::` to `RubySaml::XML::`. Please search your
36-
codebase for `XMLSecurity::` and replace it as appropriate. In addition, you must replace direct usage of
35+
RubySaml version `2.0.0` changes the namespace `::XMLSecurity` to `::RubySaml::XML`. Please search your
36+
codebase for `XMLSecurity` and replace it as appropriate. In addition, you must replace direct usage of
3737
`require 'xml_security'` with `require 'ruby_saml/xml'`.
3838

3939
For backward compatibility, if the constant `XMLSecurity` is not already defined by another gem, it will
@@ -174,6 +174,16 @@ and `#format_private_key` methods. Specifically:
174174
stripped out.
175175
- Case 7: If no valid certificates are found, the entire original string will be returned.
176176

177+
## Updating from 1.17.x to 1.18.0
178+
179+
Version `1.18.0` changes the way the toolkit validates SAML signatures. There is a new order
180+
how validation happens in the toolkit and also the toolkit by default will check malformed doc
181+
when parsing a SAML Message (`settings.check_malformed_doc`).
182+
183+
The SignedDocument class defined at xml_security.rb experienced several changes.
184+
We don't expect compatibilty issues if you use the main methods offered by ruby-saml, but if
185+
you use a fork or customized usage, is possible that you need to adapt your code.
186+
177187
## Updating from 1.12.x to 1.13.0
178188

179189
Version `1.13.0` adds `settings.idp_sso_service_binding` and `settings.idp_slo_service_binding`, and
@@ -247,7 +257,7 @@ The new preferred way to provide _SAMLResponse_, _RelayState_, and _SigAlg_ is v
247257
# In this example `query_params` is assumed to contain decoded query parameters,
248258
# and `raw_query_params` is assumed to contain encoded query parameters as sent by the IDP.
249259
settings = {
250-
settings.security[:signature_method] = RubySaml::XML::Document::RSA_SHA1
260+
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA1
251261
settings.soft = false
252262
}
253263
options = {
@@ -260,7 +270,7 @@ options = {
260270
"RelayState" => raw_query_params["RelayState"],
261271
},
262272
}
263-
slo_logout_request = RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
273+
slo_logout_request = OneLogin::RubySaml::SloLogoutrequest.new(query_params["SAMLRequest"], settings, options)
264274
raise "Invalid Logout Request" unless slo_logout_request.is_valid?
265275
```
266276

0 commit comments

Comments
 (0)