Commit 79ee819c authored by GitLab Release Tools Bot's avatar GitLab Release Tools Bot

Merge remote-tracking branch 'dev/13-7-stable' into 13-7-stable

parents 1ef3b81f 2f14978e
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
documentation](doc/development/changelog.md) for instructions on adding your own documentation](doc/development/changelog.md) for instructions on adding your own
entry. entry.
## 13.7.4 (2021-01-13)
### Security (1 change)
- Deny implicit flow for confidential apps.
## 13.7.3 (2021-01-08) ## 13.7.3 (2021-01-08)
### Fixed (7 changes) ### Fixed (7 changes)
......
13.7.3 13.7.4
\ No newline at end of file \ No newline at end of file
13.7.3 13.7.4
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController ...@@ -4,7 +4,7 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
include Gitlab::Experimentation::ControllerConcern include Gitlab::Experimentation::ControllerConcern
include InitializesCurrentUserMode include InitializesCurrentUserMode
before_action :verify_confirmed_email! before_action :verify_confirmed_email!, :verify_confidential_application!
layout 'profile' layout 'profile'
...@@ -24,18 +24,19 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController ...@@ -24,18 +24,19 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
end end
end end
def create private
# Confidential apps require the client_secret to be sent with the request. # Confidential apps require the client_secret to be sent with the request.
# Doorkeeper allows implicit grant flow requests (response_type=token) to # Doorkeeper allows implicit grant flow requests (response_type=token) to
# work without client_secret regardless of the confidential setting. # work without client_secret regardless of the confidential setting.
if pre_auth.authorizable? && pre_auth.response_type == 'token' && pre_auth.client.application.confidential # This leads to security vulnerabilities and we want to block it.
render "doorkeeper/authorizations/error" def verify_confidential_application!
else render 'doorkeeper/authorizations/error' if authorizable_confidential?
super
end
end end
private def authorizable_confidential?
pre_auth.authorizable? && pre_auth.response_type == 'token' && pre_auth.client.application.confidential
end
def verify_confirmed_email! def verify_confirmed_email!
return if current_user&.confirmed? return if current_user&.confirmed?
......
...@@ -51,10 +51,27 @@ RSpec.describe Oauth::AuthorizationsController do ...@@ -51,10 +51,27 @@ RSpec.describe Oauth::AuthorizationsController do
end end
end end
shared_examples "Implicit grant can't be used in confidential application" do
context 'when application is confidential' do
before do
application.update(confidential: true)
params[:response_type] = 'token'
end
it 'does not allow the implicit flow' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/error')
end
end
end
describe 'GET #new' do describe 'GET #new' do
subject { get :new, params: params } subject { get :new, params: params }
include_examples 'OAuth Authorizations require confirmed user' include_examples 'OAuth Authorizations require confirmed user'
include_examples "Implicit grant can't be used in confidential application"
context 'when the user is confirmed' do context 'when the user is confirmed' do
let(:confirmed_at) { 1.hour.ago } let(:confirmed_at) { 1.hour.ago }
...@@ -95,26 +112,14 @@ RSpec.describe Oauth::AuthorizationsController do ...@@ -95,26 +112,14 @@ RSpec.describe Oauth::AuthorizationsController do
subject { post :create, params: params } subject { post :create, params: params }
include_examples 'OAuth Authorizations require confirmed user' include_examples 'OAuth Authorizations require confirmed user'
include_examples "Implicit grant can't be used in confidential application"
context 'when application is confidential' do
before do
application.update(confidential: true)
params[:response_type] = 'token'
end
it 'does not allow the implicit flow' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/error')
end
end
end end
describe 'DELETE #destroy' do describe 'DELETE #destroy' do
subject { delete :destroy, params: params } subject { delete :destroy, params: params }
include_examples 'OAuth Authorizations require confirmed user' include_examples 'OAuth Authorizations require confirmed user'
include_examples "Implicit grant can't be used in confidential application"
end end
it 'includes Two-factor enforcement concern' do it 'includes Two-factor enforcement concern' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment