开发者社区> jerrywangsap> 正文

关于 SAP Spartacus OAuth 2.0 Resource Owner Password Flow 实现的一些讨论

简介: 关于 SAP Spartacus OAuth 2.0 Resource Owner Password Flow 实现的一些讨论
+关注继续查看

McAfee discovered that it is possible to retrieve a valid authentication token for a user, using an unauthenticated request to the application’s backend API.


通过没有认证的请求,调用后台API,获取某个用户的Authentication token.


The application uses OpenID Connect OAuth 2.0 to authenticate users.


The OAuth 2.0 framework supports different flows that can be implemented by an application to retrieve user access tokens.


During testing, McAfee observed that the application appears to implement the Authorization Code Flow directly from the client application, using client-side JavaScript code to generate the POST request to retrieve the access token, which includes a client_id and client_secret parameter in the request. This is not appropriate for a single-page application (SPA) such as this, as it exposes the client_id and client_secret information to the client, either via embedded JavaScript source, or using an interception proxy.


client_id=mobile_android&client_secret=secret&grant_type=password&username=ct******@gmail.com&password=


Authentication Flow

Spartacus 2.1 uses what is called “Resource Owner Password Flow” or “Code Flow” as it’s called in the issue description.


“Resource Owner Password Flow” is the only flow fully supported by the SAP Commerce backend.


Spartacus 2.1 has built-in support for only this flow. Spartacus 3.0+ can be configured to work with alternate flows, but again, the alternate flows are not fully supported by the SAP Commerce backend.


As a reference, here is the spartacus 3.0 documentation that provides more info about this:


https://sap.github.io/spartacus-docs/session-management/#configuring-authorization-code-flow-or-implicit-flow


Spartacus exposes the “client_id” and “secret”.

Some backend endpoints like “customer registration” and “forgot your password” require a “client” authentication before they can be called.


This “client” authentication is performed by authenticating with a grant type of “client_credentials”. The access token provided for a “client_credentials” authentication is not associated with a specific user and only allows an occ client to call a handful of endpoints that don’t otherwise require a user authentication.


Someone could discover the “client” credentials (“client_id” and “secret”) using the browser dev tools, but these credentials can only be used to get a “client” access token and call endpoints that already do not require any user authentication.


This backend api behaves like this by design and Spartacus needs to comply with this contract.


The authentication endpoint allows account enumeration.

I tried to reproduce the issue from the information provided and I could not.Using the “grant type” of “password” in the authentication request gave the following response whenever the correct password was not provided:

{ "error": "invalid_grant", "error_description": "Bad credentials"}

There was no difference between an attempt with a username that exists and attempts with a username that does not exist in the system.


Therefore I can not see an account enumeration vulnerability with the observed behaviour.


Using a “grant type” of “client_credentials”, the user in the request is ignored and a “client” token is returned with no access to customer restricted endpoints.


You can perhaps double check the “grant type” used in the authentication requests or provide us with updated repro steps.


Auth requests can obtain an access token for a user without knowing his password

I tried to reproduce the issue from the information provided and I could not. I observed the expected behaviour.


If you post an authentication request with a “grant_type” of “client_credentials”, the access token will be generated for a “client” authentication based on “client_id” and “secret” regardless if a username is also provided in the post request.


The “client” authentication token will not work with user restricted endpoints.


If you post an authentication request with a “grant_type” of “password”, the backend will only authenticate a given user when the correct password is provided.


I was not able to get an access token for an existing user without providing his password.


Perhaps try the use case again and double check which “grant_type” is provided or provide us with updated repro steps.


Spartacus uses a new user session if a valid token is pasted in local storage.

While this is not a supported use case, this is not a security flaw. To get a user access token, a valid username/password pair needs to be provided to the auth endpoint.



版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
SAP 电商云 Spartacus UI Delivery Mode ID 的 validator
SAP 电商云 Spartacus UI Delivery Mode ID 的 validator
26 0
关于 SAP Spartacus OAuth 2.0 Resource Owner Password Flow 实现的一些讨论
关于 SAP Spartacus OAuth 2.0 Resource Owner Password Flow 实现的一些讨论
62 0
SAP ABAP Fiori Launchpad role based page - cached_sap_menu - 基于角色的页面显示原理
Created by Jerry Wang, last modified on Aug 26, 2015 GET_ROLE_BASED_PAGE_USAGES GET_START_UP_MENU cached_navigation_tree /ui2/nwbc_nav_tr SUSR_USER_LOGONDATA_GET IMPORT FROM DATABASE session buffer get_user_info get_roles Read list of roles for the user: NAVIGATION_SELECT_AGRS_OF_USER PRGN_READ_ROLE
67 0
SAP Fiori Launchpad上的错误消息 - User Parameter /UI2/WD_TRKORR_CUST is not maintained
Created by Jerry Wang, last modified on Mar 11, 2015 Issue: You meet with the following error message in Fiori UI:
79 0
SAP Fiori Launchpad get role based page usages
SAP Fiori Launchpad get role based page usages
58 0
SAP Spartacus的user id
SAP Spartacus的user id
42 0
Cloud for Customer里权限控制Business Role和Access context的截图
Cloud for Customer里权限控制Business Role和Access context的截图
46 0
SAP Spartacus 成功登录之后,请求 base site 到底需不需要 Access Token
SAP Spartacus 成功登录之后,请求 base site 到底需不需要 Access Token
71 0
SAP Spartacus Organization Unit User页面的实现层级结构
SAP Spartacus Organization Unit User页面的实现层级结构
47 0
SAP Spartacus读取User Address的action是如何被Effect接收的
SAP Spartacus读取User Address的action是如何被Effect接收的
29 0
+关注
jerrywangsap
文章
问答
视频
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
Apache Wicket User Guide - Ref
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载