Conversation
Signed-off-by: nikolay <n.atanasow94@gmail.com>
|
One additional issue we should address in this follow-up is the logging of sensitive keys in the config service. At startup, the config service prints all configuration values. Since PAYMASTER_ACCOUNTS may include private keys, those keys should be masked in the logs. We should ensure that only private keys are masked. Other fields such as account ID or allowance should remain visible, as they can be helpful during debugging. |
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Fixed. |
Signed-off-by: nikolay <n.atanasow94@gmail.com>
simzzz
left a comment
There was a problem hiding this comment.
Looks good, I left two suggestions
packages/relay/src/lib/services/ethService/ethCommonService/CommonService.ts
Show resolved
Hide resolved
packages/relay/src/lib/services/ethService/ethCommonService/CommonService.ts
Outdated
Show resolved
Hide resolved
| | `PAYMASTER_ENABLED` | "false" | Flag to enable or disable the Paymaster functionally | | ||
| | `PAYMASTER_WHITELIST` | "[]" | List of "to" addresses that will have fully subsidized transactions if the gasPrice was set to 0 by the signer | | ||
| | `PAYMASTER_ACCOUNTS` | "[]" | List of potential paymaster accounts that can be used alongside or instead of the default operator. Allows multiple paymasters without deploying separate instances per contract or address. Each entry defines [[accountId, type ("HEX_ECDSA", "HEX_ED25519"), key, allowance], [account, type, key, allowance]], e.g. `PAYMASTER_ACCOUNTS=[["0.0.9303","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","80"],["0.0.5644","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","100"]]` | | ||
| | `PAYMASTER_ACCOUNTS` | "[]" | List of potential paymaster accounts that can be used alongside or instead of the default operator. Allows multiple paymasters without deploying separate instances per contract or address. Each entry defines [[accountId, type ("HEX_ECDSA", "HEX_ED25519"), key, allowanceInHBAR], [account, type, key, allowanceInHBAR]], e.g. `PAYMASTER_ACCOUNTS=[["0.0.9303","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","80"],["0.0.5644","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","350"]]` | |
There was a problem hiding this comment.
Looking back at this, PAYMASTER_ACCOUNTS and PAYMASTER_ACCOUNTS_WHITELISTS are both simple string arrays, but there is no defined contract around the positions. For example, there is nothing enforcing that index 0 must be the account, index 1 the type, index 2 the key, and so on. This means values can be passed in any order and ConfigService will still accept them, only failing at runtime.
We should address this so that invalid configurations are caught at build time instead.
There was a problem hiding this comment.
Added start-up validation.
packages/relay/src/lib/services/ethService/ethCommonService/CommonService.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: nikolay <n.atanasow94@gmail.com>
| GlobalConfig.ENTRIES[envName].type === 'string' && !!this.GITHUB_SECRET_PATTERN.exec(envValue ?? ''); | ||
| static maskUpEnv(envName: string, envValue: string | undefined | string[][]): string { | ||
| // explicitly listed as sensitive | ||
| const sensitiveInfo = this.SENSITIVE_FIELDS_MAP.get(envName as ConfigKey); |
There was a problem hiding this comment.
Now we have to be aware that:
- Every variable passed to our app through environment variables will be printed (and therefore exposed) by default, whether we intend it or not.
- We also need to know where and which variable must be updated to prevent it. In practice, you have to modify the variable in
loggerService, not inconfigService, which makes the setup even more confusing (keeping it as it is would make more sense if the logger service depended on an abstraction likeconfigInterface.sensitiveFieldsinstead of the actual definition with hardcoded field names here)
Overall, it's usually safer to do it the other way around. For example, having a public flag next to the variable definition would make it printable, while leaving it omitted would mask it by default.Now we can unintentionally expose critical value (and it can happen in a lots of unpredictable scenarios, for example once we start storing logs in Graylog, even local execution of the application could generate dangerous leaks if a config variable is added before the logger service is properly configured. And when you add new variable you ususally start with that...
There was a problem hiding this comment.
- That's how it's worked so far, right?
- It makes more sense to me to let them in
loggerServicebecauseLoggerServiceis doing the printing and only it requires this information, whether the field is sensitive or not.
Adding a new flag for each config var is so much copy-pasted code IMO. If the team decides it's a better solution, I'll implement it.
@quiet-node @simzzz, what do you think?
There was a problem hiding this comment.
I think the point is good and having to remember to add sensitive fields to loggerService is not optimal, and opt-in to printing would be more secure, however it's out of scope for this PR and changing the entire logging architecture seems unnecessary. Maybe you could raise a ticket and promote it so that we can discuss it further? @jasuwienas
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #5032 +/- ##
==========================================
+ Coverage 95.81% 95.91% +0.09%
==========================================
Files 144 144
Lines 24662 24717 +55
Branches 1966 1983 +17
==========================================
+ Hits 23631 23707 +76
+ Misses 1003 982 -21
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 9 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Description
There were several items that had to be resolved on #5016, but due to the urgency of it, we decided to create a follow-up PR.
Related issue(s)
Fixes #4977
Testing Guide
Changes from original design (optional)
N/A
Additional work needed (optional)
N/A
Checklist