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

Unexpected '00' Byte After mnauth_challenge in Version Message #5701

Open
dinno-invis1ble opened this issue Nov 15, 2023 · 0 comments
Open

Comments

@dinno-invis1ble
Copy link

When connecting to my node using P2P, I've noticed an additional '00' byte after the mnauth_challenge in the version message. I'm unsure if this byte should be considered padding and if it can be safely ignored. The parsing code appears to handle this situation, but I'd like clarification on whether this behavior is expected or if there's a recommended course of action.

I am using @dashpay/dashcore-p2p to connect to my node.

Parsing Code:

function(payload) {
  var parser = new BufferReader(payload);
  this.version = parser.readUInt32LE();
  this.services = parser.readUInt64LEBN();
  this.timestamp = new Date(parser.readUInt64LEBN().toNumber() * 1000);

  this.addrMe = {
    services: parser.readUInt64LEBN(),
    ip: utils.parseIP(parser),
    port: parser.readUInt16BE()
  };
  this.addrYou = {
    services: parser.readUInt64LEBN(),
    ip: utils.parseIP(parser),
    port: parser.readUInt16BE()
  };
  this.nonce = parser.read(8);
  this.subversion = parser.readVarLengthBuffer().toString();
  this.startHeight = parser.readUInt32LE();

  if(parser.finished()) {
    this.relay = true;
  } else {
    this.relay = !!parser.readUInt8();
  }
  if(parser.finished()) {
    this.mnAuthChallenge = null;
  } else if (this.version >= 70214) {
    this.mnAuthChallenge = parser.read(32).toString('hex');
  }
	if(parser.buf.length - parser.pos === 1) {
		const padding = parser.read(1).toString('hex')
		if(padding !== '00') {
			console.warn('Padding in version message is not 00')
		}
	}
  utils.checkFinished(parser);
}

Received Version Message:
54120100050c0000000000001fce5465000000000000000000000000000000000000000000000000000000000000050c00000000000000000000000000000000000000000000000059598cfa03090524122f4461736820436f72653a31392e332e302f3c161e0001038fa544e1069133d3e1b65c5b41197ad43fb3ec508ca6ca111a88bc2425d06c00

Additionally, the provided parsing code includes a check for a single '00' byte at the end of the buffer. Is this expected behavior, and should it be handled in a specific way?

Any guidance or insights would be appreciated. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant