machina-auth 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b6572b3ef8cb554a701292ebeca7442e4267c7fea9f3c8fc8635067f02ce6fc
|
|
4
|
+
data.tar.gz: 0e25ba27df749426535443c1c8ff5b165e1ed02658d15ced035f9256b3ed731f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19fb58e16fd547814694f94b976ad0baebd1fb2740ffabf709c28a6ed6ab614bb75ad58ac40743d791c51cbf1840700baad43c63ba4bc5518551d6d3a6eb60db
|
|
7
|
+
data.tar.gz: 9e710c4519b897849a7d29dd0b93663a94627b5141d89893493decb2f16d3de4d9621b25db6080cae340916cf4b92c860dba6d9e5fe8a21350e7820f30229d57
|
|
@@ -39,11 +39,12 @@ module Machina
|
|
|
39
39
|
}
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
# Relative paths only
|
|
43
|
-
# open redirect on a credential-bearing
|
|
42
|
+
# Relative paths only. Reject a leading // or /\ — browsers treat both as
|
|
43
|
+
# protocol-relative, so either is an open redirect on a credential-bearing
|
|
44
|
+
# request (a backslash also trips Rails' UnsafeRedirectError as a 500).
|
|
44
45
|
def safe_return_to
|
|
45
46
|
value = params[:return_to].to_s
|
|
46
|
-
return value if value.start_with?('/') && !value.
|
|
47
|
+
return value if value.start_with?('/') && !value.match?(%r{\A/[/\\]})
|
|
47
48
|
|
|
48
49
|
'/'
|
|
49
50
|
end
|
data/lib/machina/version.rb
CHANGED
|
@@ -68,6 +68,12 @@ RSpec.describe Machina::CallbacksController, type: :controller do
|
|
|
68
68
|
|
|
69
69
|
expect(response).to redirect_to('/')
|
|
70
70
|
end
|
|
71
|
+
|
|
72
|
+
it 'rejects a backslash protocol-relative return_to' do
|
|
73
|
+
get :show, params: { token:, state:, return_to: '/\\evil.example.com' }
|
|
74
|
+
|
|
75
|
+
expect(response).to redirect_to('/')
|
|
76
|
+
end
|
|
71
77
|
end
|
|
72
78
|
|
|
73
79
|
describe 'with an invalid state' do
|