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

TS_VERIFY_CTX_init is required by yara >= 4.3.0 #1006

Closed
orbea opened this issue Feb 25, 2024 · 5 comments
Closed

TS_VERIFY_CTX_init is required by yara >= 4.3.0 #1006

orbea opened this issue Feb 25, 2024 · 5 comments

Comments

@orbea
Copy link

orbea commented Feb 25, 2024

OS: Gentoo
libressl: 3.8.2
yara: >= 4.3.0

When building yara it fails with implicit function declarations for TS_VERIFY_CTX_init.

libyara/modules/pe/authenticode-parser/countersignature.c: In function 'ms_countersig_new':
libyara/modules/pe/authenticode-parser/countersignature.c:302:3: error: implicit declaration of function 'TS_VERIFY_CTX_init'; did you mean 'TS_VERIFY_CTX_new'? [-Werror=implicit-function-declaration]
  302 |   TS_VERIFY_CTX_init(ctx);
      |   ^~~~~~~~~~~~~~~~~~
      |   TS_VERIFY_CTX_new
cc1: some warnings being treated as errors

yara-4.4.0-build.log

This was added to yara 4.3.0 in commit VirusTotal/yara@b9cd46d and is visible in their code base here.

I do not see any OpenSSL documentation for this function, but it looks relatively simple looking at their code which is visible here.

 void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx)
{
    OPENSSL_assert(ctx != NULL);
    memset(ctx, 0, sizeof(*ctx));
}

Are there reasons why this function was not added to LibreSSL when other TS_VERIFY_CTX_ functions were added? Or was it just because it was not needed at the time?

I also made this issue for the Gentoo LibreSSL overlay. gentoo/libressl#550

@orbea
Copy link
Author

orbea commented Feb 25, 2024

It does compile if TS_VERIFY_CTX_init is commented in yara, but I am not sure if that is correct?

@botovq
Copy link
Contributor

botovq commented Feb 25, 2024

It was removed since it serves no purpose with opaque TS_VERIFY_CTX, either it zeroes out an already zero ctx, or it causes leaks. The correct fix is to remove this call in yara. TS_VERIFY_CTX_new() has always zeroed the allocated ctx since the very beginning.

orbea added a commit to orbea/yara that referenced this issue Feb 25, 2024
This is redundant and already handled by TS_VERIFY_CTX_new().
Additionally it causes build failures with LibreSSL >= 3.8.0 which
removed this function since it serves no purpose with opaque
TS_VERIFY_CTX where it will zero out an already zero'd out ctx or cause
a leak.

See: libressl/portable#1006
@orbea
Copy link
Author

orbea commented Feb 25, 2024

Thanks for the explanation, I made a PR for yara here. VirusTotal/yara#2044

@orbea
Copy link
Author

orbea commented Feb 25, 2024

There are some test failures in yara, the second of which I am unsure if its related to LibreSSL?

VirusTotal/yara#2045
VirusTotal/yara#2046

plusvic pushed a commit to VirusTotal/yara that referenced this issue Feb 26, 2024
This is redundant and already handled by TS_VERIFY_CTX_new().
Additionally it causes build failures with LibreSSL >= 3.8.0 which
removed this function since it serves no purpose with opaque
TS_VERIFY_CTX where it will zero out an already zero'd out ctx or cause
a leak.

See: libressl/portable#1006
@orbea
Copy link
Author

orbea commented Feb 26, 2024

The fix was merged into yara, thanks for your time!

I will close this issue now, but there might be further issues documented in issue VirusTotal/yara#2046.

@orbea orbea closed this as completed Feb 26, 2024
metthal added a commit to avast/authenticode-parser that referenced this issue Mar 2, 2024
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

2 participants