亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

HTTP 安全配置authorizeRequests() 出現 Sonar 嚴重缺陷

HTTP 安全配置authorizeRequests() 出現 Sonar 嚴重缺陷

holdtom 2023-12-13 16:41:39
我有一個 Spring Boot 應用程序,在調用 AuthorizeRequests() 的行中,我的配置函數出現以下聲納嚴重缺陷。我應該如何修復它?謝謝。Make sure that Permissions are controlled safely here. Controlling permissions is security-sensitive.  It has led in the past to the following vulnerabilities: CVE-2018-12999 CVE-2018-10285 CVE-2017-7455我的配置類:@Configuration@EnableWebSecuritypublic class MyConfig extends WebSecurityConfigurerAdapter {      @Override      protected void configure(HttpSecurity http) throws Exception {      http                    .authorizeRequests()  // Sonar complain this line here        .antMatchers("/v1/").permitAll()        .antMatchers("/**").authenticated()        .and().httpBasic()        .and().cors();   }}
查看完整描述

1 回答

?
眼眸繁星

TA貢獻1873條經驗 獲得超9個贊

我剛剛查找了聲納中的錯誤描述,下面是聲納中的錯誤描述。

控制權限是安全敏感的。它在過去導致了以下漏洞:

  • CVE-2018-12999

  • CVE-2018-10285

  • CVE-2017-7455

攻擊者只能破壞他們有權訪問的內容。因此,限制他們的訪問是防止他們造成嚴重破壞的好方法,但必須采取正確的做法。

此規則標記控制對資源和操作的訪問的代碼。目標是指導安全代碼審查。

以下是導致聲納問題的代碼

.authorizeRequests()  // Sonar complain this line here

.antMatchers("/v1/").permitAll()

.antMatchers("/**").authenticated()

正如我在您的問題的評論中提到的,不要盲目授權請求,訪問應該受到限制,如下所示


http.authorizeRequests()

  .antMatchers("/", "/home").access("hasRole('USER')")

  .antMatchers("/admin/**").hasRole("ADMIN")

  .and()

  // some more method calls

如果這是您的測試/非生產代碼,只需在抱怨問題的行添加//NOSONAR,聲納將繞過它,但**不要在生產環境中使用//NOSONAR。


查看完整回答
反對 回復 2023-12-13
  • 1 回答
  • 0 關注
  • 306 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號