Skip to content

Conversation

@martintomazic
Copy link
Contributor

@martintomazic martintomazic commented Oct 6, 2025

Motivation: Fixes Audit go dependencies. See vulnerability.

Consideration:
v.1.20 was breaking, after a quick glance we should not be affected.

@netlify
Copy link

netlify bot commented Oct 6, 2025

Deploy Preview for oasisprotocol-oasis-core canceled.

Name Link
🔨 Latest commit 8045b42
🔍 Latest deploy log https://app.netlify.com/projects/oasisprotocol-oasis-core/deploys/68e3bd3326a04a0008ddbc63

Comment on lines -6 to -10
// v1.5.0 has broken uint parsing, use my commit with fixes instead until
// the maintainers merge my PR: https://github.com/spf13/cast/pull/144
github.com/spf13/cast => github.com/oasisprotocol/cast v0.0.0-20220606122631-eba453e69641
// v1.18.0+ has broken handling of bound flags.
github.com/spf13/viper => github.com/spf13/viper v1.17.0
Copy link
Contributor Author

@martintomazic martintomazic Oct 6, 2025

Choose a reason for hiding this comment

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

Quickly looking at the cast PR mentioned this was fixed upstream.

Not sure about bound flags error (pending a check)

Copy link
Collaborator

Choose a reason for hiding this comment

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

cast: The minimal working example now works, so it looks that it was fixed.
viper: Unit tests with v18.0 pass, so this problem is not captured with our tests. @kostko any idea what was wrong and if this has been fixed?

Copy link
Contributor Author

@martintomazic martintomazic Oct 6, 2025

Choose a reason for hiding this comment

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

Not sure about bound flags error (pending a check)

This is still an issue in the newer versions. E.g. running e2e/runtime/runtime-dynamic scenario previously MaxInRuntimeMessages was set to 128 but after this change is set to 0, thus this check fails.
rt.Executor.MaxMessages and params.MaxRuntimeMessages were set to 0 and 128 respectively, but after this change this value is swapped, thus this check fails.

Happy to work on that but I assume this will not be a trivial fix, else it would have been done at that time already?

Copy link
Contributor Author

@martintomazic martintomazic Oct 6, 2025

Choose a reason for hiding this comment

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

Unit tests with v18.0 pass, so this problem is not captured with our tests.

It seems this is only relevant for e2e tests, where we do all the config gymnastics... Maybe is not even that hard to fix... update: or not captured via unit as you say.

Copy link
Member

Choose a reason for hiding this comment

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

This was more relevant in the past where flags were used for everything. Now most things are passed via the YAML config file. So it shouldn't be that hard to work around?

Copy link
Contributor Author

@martintomazic martintomazic Oct 7, 2025

Choose a reason for hiding this comment

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

Now most things are passed via the YAML config file. So it shouldn't be that hard to work around?

We still do this for the genesis command which seems to be the reason why e2e/runtime/runtime-dynamic scenario is failing. Moreover, searching for viper.BindPFlags, it seems there are quite many places that rely on this pattern.

I tried debugging example above, to see why the default value is no longer used after this upgrade:

  1. During package init we store the default value into initGenesisFlags.
  2. Bind initGenesisFlags to viper.
  3. Add initGenesisFlags to initGenesisCmd flags.
  4. Read CfgRoothashMaxRuntimeMessages during genesis init command execution.
    • (Why not pass init genesis flagset explicitly and read from there?

I see two possible reasons why this upgrade broke things:

Related to above, (ideally) we should try to avoid global state (config) and init functions as they makes code hard to reason and test. Furthermore, as from the documentation viper global instance may get deprecated .

Given my limited knowledge of pflags, viper and cobra this seems far from trivial task, taking the above anti-patterns into consideration. (That does not mean I am not willing to spent time fixing it).

Since this is blocking master, my suggestion would be to temporary add CVE-2025-11065 to .nancy-ignore, unless we find a simple solution for it tmr.

Copy link
Member

Choose a reason for hiding this comment

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

Since we use the config file for most things now, why use viper at all? Just use the flags directly. It shouldn't be too hard to change that, at least in the affected locations.

Copy link
Member

Choose a reason for hiding this comment

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

Added CVE-2025-11065 to .nancy-ignore until 2025-12-01 as the vulnerability seems quite irrelevant so we can do this bump in peace.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So the last commit in this PR should also undo commit de3cc372d902ceec8f04c8e40b74676e580d345d from #6348.

@martintomazic
Copy link
Contributor Author

Anything in particular you would recommend to test/could be broken after this upgrade?

@martintomazic martintomazic force-pushed the martin/internal/bump-viper branch from 23f2f38 to 8045b42 Compare October 6, 2025 12:59
@martintomazic martintomazic marked this pull request as ready for review October 6, 2025 13:08
@martintomazic
Copy link
Contributor Author

^^ Nice CI caught smtg, will explore :):

level=error ts=2025-10-06T13:09:56.471894282Z caller=root.go:448 module=test-runner msg="failed to run scenario" err="root: failed to run scenario: failed to register runtime: failed to submit tx: exit status 1" scenario=e2e/runtime/trust-root/change run_id=0

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

Successfully merging this pull request may close these issues.

4 participants