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

#736 Generate hash and sign/verify data for secrettext values #1005

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TKapitan
Copy link
Contributor

@TKapitan TKapitan commented Apr 27, 2024

Summary

New overloaded procedures for Hash and Sign/Verify that accept SecretText value as hash/sign input value.

Work Item(s)

Fixes #736

Fixes AB#507370

@TKapitan TKapitan requested a review from a team as a code owner April 27, 2024 07:18
@github-actions github-actions bot added AL: System Application From Fork Pull request is coming from a fork labels Apr 27, 2024
@github-actions github-actions bot added this to the Version 25.0 milestone Apr 27, 2024
Copy link
Contributor

@darjoo darjoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the change of where the unwrapping happens, looks fine.

begin
exit(GenerateHash(InputString.Unwrap(), Key, HashAlgorithmType));
end;

[NonDebuggable]
procedure GenerateHash(InputString: Text; "Key": SecretText; HashAlgorithmType: Option HMACMD5,HMACSHA1,HMACSHA256,HMACSHA384,HMACSHA512): Text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this function to take in SecretText for the InputString and unwrap the value only here. While the rest of the functions can pass either Text or SecretText until it gets to this.
Add overloads as needed.

We don't want to unwrap any SecretText outside of the location it is actually being used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the logic to the procedure with secret text and have the other procedure call it, so you dont have to duplicate the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to do the same for other procedures.

@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Apr 30, 2024
@aholstrup1 aholstrup1 added the Linked Issue is linked to a Azure Boards work item label Apr 30, 2024
@BazookaMusic
Copy link
Contributor

BazookaMusic commented Apr 30, 2024

@darjoo , @WaelAbuSeada
I'm not sure it's a good idea to let this go in. This can allow
an attacker to brute force the contents of a secrettext.

The way they would do it is to simply write a brute force search comparing the secret text with different combinations and then adding a breakpoint inside an if statement chrcking if the password matches.

begin
exit(GenerateHash(InputString.Unwrap(), Key, HashAlgorithmType));
end;

[NonDebuggable]
procedure GenerateHash(InputString: Text; "Key": SecretText; HashAlgorithmType: Option HMACMD5,HMACSHA1,HMACSHA256,HMACSHA384,HMACSHA512): Text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the logic to the procedure with secret text and have the other procedure call it, so you dont have to duplicate the code.

begin
exit(GenerateHash(InputString.Unwrap(), Key, HashAlgorithmType));
end;

[NonDebuggable]
procedure GenerateHash(InputString: Text; "Key": SecretText; HashAlgorithmType: Option HMACMD5,HMACSHA1,HMACSHA256,HMACSHA384,HMACSHA512): Text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to do the same for other procedures.

@darjoo
Copy link
Contributor

darjoo commented May 1, 2024

@darjoo , @WaelAbuSeada I'm not sure it's a good idea to let this go in. This can allow an attacker to brute force the contents of a secrettext.

The way they would do it is to simply write a brute force search comparing the secret text with different combinations and then adding a breakpoint inside an if statement chrcking if the password matches.

@TKaptian Could you let us know the scenarios you have that require this? What type of values are in the secrettext and why that needs to be hashed?

@JesperSchulz JesperSchulz added the Follow Up The issue has an open question and must be followed up on label May 13, 2024
@pri-kise
Copy link
Contributor

@darjoo there's an thread on yammer about this topic:
https://www.yammer.com/dynamicsnavdev/threads/2808751498059776

I think one good example is to use this for Basic Authentication that requires a Base64 hash.
e.g. if you want to implement something similiar to the procedure ToBase64(String: SecretText) Base64String: SecretText here:

local procedure ToBase64(String: SecretText) Base64String: SecretText

I know that there exists better authentication methods than base64 but sometimes we aren't in the control of the external service and the external service only provides simple authentication methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AL: System Application Follow Up The issue has an open question and must be followed up on From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BC Idea]: GenerateHash() with InputString: SecretText
7 participants