我正在使用BreezeJS,並對如何保存數據有疑問。這裏是我的代碼和註釋BreezeJS SaveChanges()安全問題
[Authorize]
/*
* I want to point out the security hole here. Any Authorized user is able to pass to this method
* a saveBundle which will be saved to the DB. This saveBundle can contain anything, for any user,
* or any table.
*
* This cannot be stopped at the client level as this method can be called from Postman, curl, or whatever.
*
* The only way I can see to subvert this attack would be to examine the saveBundle and verify
* no data is being impacted that is not owned or related directly to the calling user.
*
* Brute force could be applied here because SaveResult contains Errors and impacted Entities.
*
*/
[HttpPost]
public SaveResult SaveChanges(JObject saveBundle)
{
return _efContext.SaveChanges(saveBundle);
}
限制訪問來獲取數據我首先從ACCESS_TOKEN user_ID的提取和限制我所有的問題,包括這在where子句中一個呼叫者的能力,使得它有些用戶不可能檢索另一個用戶數據。
但是,這不會阻止具有有效access_token的流氓用戶在增量對象id的強力循環中調用SaveChanges()。
我在這一個路上?也許我錯過了一些東西。
感謝您的任何幫助。
麥克
不熟悉微風,但你聽起來像你正在實施適當的訪問控制。在生成對象標識符時使用加密隨機性也是一種很好的做法,但實際上這對於實施適當的訪問控制來說是次要的。在SaveChanges()方面,您可能希望限制用戶可以執行的保存操作的數量 - 否則他可以用垃圾填充數據庫。 – TheGreatContini