Skip to content

Commit

Permalink
Upgrade Sinatra and Rack to fix vulnerability
Browse files Browse the repository at this point in the history
The security alert says:

> [sinatra is] vulnerable to Reliance on Untrusted Inputs in a Security
> Decision via the X-Forwarded-Host (XFH) header. When making a request to
> a method with redirect applied, it is possible to trigger an Open
> Redirect Attack by inserting an arbitrary address into this header. If
> used for caching purposes, such as with servers like Nginx, or as a
> reverse proxy, without handling the X-Forwarded-Host header, attackers
> can potentially exploit Cache Poisoning or Routing-based SSRF.

See https://github.com/gma/nesta/security/dependabot/28 for details.
  • Loading branch information
gma committed Nov 5, 2024
1 parent a3debc7 commit f0ff629
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 0.17.0 (Unreleased)

* Update Sinatra to verion 4.0, to fix a vulnerability. This has also
required a jump to Rack 3. (Graham Ashton)

* Update Sass parser to sass-embedded 1.80, which (due to changes in CSS 4)
deprecates the global colour functions and the @import statement. Any Sass
code that uses these features will need updating before Dart Sass 3.0 is
Expand Down
19 changes: 11 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ PATH
RedCloth (~> 4.2)
haml (>= 3.1, < 6.0)
haml-contrib (>= 1.0)
rack (~> 2)
rack (~> 3)
rake
rdiscount (~> 2.1)
sass-embedded (~> 1.58)
sinatra (~> 3.1)
sinatra (~> 4.0)
tilt (~> 2.1)

GEM
Expand Down Expand Up @@ -64,10 +64,12 @@ GEM
racc (~> 1.4)
public_suffix (6.0.1)
racc (1.8.1)
rack (2.2.10)
rack-protection (3.2.0)
rack (3.1.8)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
raindrops (0.20.1)
Expand All @@ -83,10 +85,11 @@ GEM
sass-embedded (1.80.6)
google-protobuf (~> 4.28)
rake (>= 13)
sinatra (3.2.0)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.2.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
temple (0.10.3)
tilt (2.4.0)
Expand Down
4 changes: 2 additions & 2 deletions nesta.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ EOF

s.add_dependency('haml', '>= 3.1', '< 6.0')
s.add_dependency('haml-contrib', '>= 1.0')
s.add_dependency('rack', '~> 2')
s.add_dependency('rack', '~> 3')
s.add_dependency('rake')
s.add_dependency('rdiscount', '~> 2.1')
s.add_dependency('RedCloth', '~> 4.2')
s.add_dependency('sass-embedded', '~> 1.58')
s.add_dependency('sinatra', '~> 3.1')
s.add_dependency('sinatra', '~> 4.0')
s.add_dependency('tilt', '~> 2.1')

# Useful in development
Expand Down

8 comments on commit f0ff629

@etc
Copy link

@etc etc commented on f0ff629 Nov 5, 2024

Choose a reason for hiding this comment

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

Thanks!

@gma
Copy link
Owner Author

@gma gma commented on f0ff629 Nov 5, 2024

Choose a reason for hiding this comment

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

@etc My pleasure. I suspect I could release 0.17.0 now, but after testing it on the effectif.com site (which works fine) I decided to go to the pub instead. I'll test another couple of real-world things first, then probably push .17 out.

@gma
Copy link
Owner Author

@gma gma commented on f0ff629 Nov 6, 2024

Choose a reason for hiding this comment

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

@etc Everything seems fine on the sites I've upgraded so far, so I've released 0.17.0

@etc
Copy link

@etc etc commented on f0ff629 Nov 6, 2024

Choose a reason for hiding this comment

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

The pub should always take precedence! Thanks again for keeping all this updated.

One small note: this update breaks support for using thin as your server, if you want to maintain the other parts of your project at their latest versions. That's because the latest release of thin that is compatible with Nesta, now, is 1.6.2—but that version of thin doesn't work with the Ruby versions 2.4 and later, since it uses ::Fixnum (the error you get is uninitialized constant Thin::Server::Fixnum (NameError). No problem overall since it's easy to use another server, such as puma. But might be worth noting this in the documentation...

@gma
Copy link
Owner Author

@gma gma commented on f0ff629 Nov 6, 2024

Choose a reason for hiding this comment

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

One small note: this update breaks support for using thin as your server

@etc Ah that's a shame. I had a look, and it's explicitly marked as being incompatible with Rack 3 in its gemspec. That's a shame, but like you say, Puma to the rescue.

I've suggested Puma in the deployment docs, rather than mentioning thin explicitly. You never know, it might support Rack 3 before long. Looks like there's a pull request that's seen some activity.

gma/nestacms.com@b990288

Cheers for letting me know.

@etc
Copy link

@etc etc commented on f0ff629 Nov 7, 2024

Choose a reason for hiding this comment

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

Great, thanks! Puma is working just fine, for me.

@gma
Copy link
Owner Author

@gma gma commented on f0ff629 Nov 7, 2024

Choose a reason for hiding this comment

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

Nice. I should probably add Puma to the default Gemfile.

I just documented Netlify, should you want to give static a go.

@etc
Copy link

@etc etc commented on f0ff629 Nov 8, 2024

Choose a reason for hiding this comment

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

That's interesting, I might explore that in future if my hosting options change. At present I'm deploying on Railway, which I migrated to after Heroku ended their free plans (I was lucky enough to sign up on a free plan there before Railway, too, ended them). It works really nicely, with everything automatically re-building after every Github push.

Please sign in to comment.