ja4 icon indicating copy to clipboard operation
ja4 copied to clipboard

/usr/local/zeek/share/zeek/site/ja4/ja4l/main.zeek > Error "bad conversion to count" in the following line numbers

Open danielguerra69 opened this issue 1 year ago • 3 comments

110: 126: 153: 177: 183: 198: 96:

danielguerra69 avatar Sep 30 '24 08:09 danielguerra69

Hi @danielguerra69 did this get resolved? No one else has reported these errors.

john-althouse avatar Jan 14 '25 15:01 john-althouse

Hey @danielguerra69 and @john-althouse

This is also for anyone else seeing the same issue in zeek reporter. I noticed the same issue. Not at insane error rate in zeek reporter but enough to be annoying. Based on what I'm seeing: packets available for zeek to analyse can arrive out of order (due to jitter, pcap hardware, million other factors). This then cause the calculation at those lines become negative value. Count then will fail and throw errors in zeek reporter.

Originally, I thought the easiest work around is clamp the value down to 0 if the calculation is negative. However, after some more thinking, it can cause some false fingerprint being generated. So the latest fix is just skip.

I tried to submit a PR but was closed by contributor without a chance to discuss. Also, I was told I'm a bot...

If anyone is looking for a "fix", the patched for ja4l/main.zeek is available here. Full link: https://github.com/ichantio/ja4/blob/patch-1/zeek/ja4l/main.zeek NOTE: I'm not the best coder so this is just me trying to get this working. It's not elegant but it works.

Copy this into your zeek <zeekpath>/share/site/packages/ja4/ja4l/main.zeek If you have different location, look for it then as usual, zeekctl check and if no error zeekctl deploy make sure to check your conn.log after to verify

The summary of the fixes is we just return when the calculation is negative so the value will just be empty in zeek log. Example:

# Original line 96
c$fp$ja4l$ja4l_c = cat(double_to_count( (c$fp$ja4l$ack - c$fp$ja4l$synack) / 2.0));

# My work around negative count
local dt = (c$fp$ja4l$ack - c$fp$ja4l$synack) / 2.0;
if (dt < 0.0) return;
c$fp$ja4l$ja4l_c = cat(double_to_count(dt));

Better have empty than throwing error in reporter.

Cheers

ichantio avatar Sep 20 '25 12:09 ichantio

Sorry about that. I was going off git history.

I still lean towards letting this go to reporter by default (JA4L should be generating errors if there is enough jitter to cause this and should not be considered reliable from that sensor).

We can gate the errors\not reporting on an optional config but this code is invoked on every connection.

On Sat, Sep 20, 2025, 5:42 AM zippymicro @.***> wrote:

ichantio left a comment (FoxIO-LLC/ja4#175) https://github.com/FoxIO-LLC/ja4/issues/175#issuecomment-3314948129

Hey @danielguerra69 https://github.com/danielguerra69 and @john-althouse https://github.com/john-althouse

This is also for anyone else seeing the same issue in zeek reporter. I noticed the same issue. Not at insane error rate in zeek reporter but enough to be annoying. Based on what I'm seeing: packets available for zeek to analyse can arrive out of order (due to jitter, pcap hardware, million other factors). This then cause the calculation at those lines become negative value. Count then will fail and throw errors in zeek reporter.

Originally, I thought the easiest work around is clamp the value down to 0 if the calculation is negative. However, after some more thinking, it can cause some false fingerprint being generated. So the latest fix is just skip.

I tried to submit a PR but was closed by contributor without a chance to discuss. Also, I was told I'm a bot...

If anyone is looking for a "fix", the patched for ja4l/main.zeek is available here. Full link: https://github.com/ichantio/ja4/blob/patch-1/zeek/ja4l/main.zeek NOTE: I'm not the best coder so this is just me trying to get this working. It's not elegant but it works.

Copy this into your zeek /share/site/packages/ja4/ja4l/main.zeek If you have different location, look for it then as usual, zeekctl check and if no error zeekctl deploy make sure to check your conn.log after to verify

The summary of the fixes is we just return when the calculation is negative so the value will just be empty in zeek log. Example:

Original line 96

c$fp$ja4l$ja4l_c = cat(double_to_count( (c$fp$ja4l$ack - c$fp$ja4l$synack) / 2.0));

My work around negative count

local dt = (c$fp$ja4l$ack - c$fp$ja4l$synack) / 2.0; if (dt < 0.0) return; c$fp$ja4l$ja4l_c = cat(double_to_count(dt));

Better have empty than throwing error in reporter.

Cheers

— Reply to this email directly, view it on GitHub https://github.com/FoxIO-LLC/ja4/issues/175#issuecomment-3314948129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7C5ABZS6UXCBUIHLRWURT3TVDU7AVCNFSM6AAAAACHBHRPXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMJUHE2DQMJSHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

J0eJ0h avatar Sep 20 '25 18:09 J0eJ0h