Skip to content

Disallow code generation from strings#241162

Open
legrego wants to merge 4 commits into
elastic:mainfrom
legrego:disallow-code-generation-from-strings
Open

Disallow code generation from strings#241162
legrego wants to merge 4 commits into
elastic:mainfrom
legrego:disallow-code-generation-from-strings

Conversation

@legrego
Copy link
Copy Markdown
Member

@legrego legrego commented Oct 29, 2025

Summary

Optionally starts Kibana with --disallow-code-generation-from-strings, which as you might guess, prevents Node.js from generating code from strings. This means in practice that language features such as eval and new Function will throw an error when called, instead of generating executable code.

The code changes here are minimal here so far, and that is due to a lot of prior work to reduce our attack surface.

Rollout

I am targeting a progressive, opt-in rollout. Local development and CI will always run with --disable-code-generation-from-strings.

The distributable will only run with --disallow-code-generation-from-strings when the KBN_DISALLOW_CODE_GEN_FROM_STRINGS environment variable is set to true. This will allow us to selectively enable within Elastic-managed environments, until such a time that we have enough confidence to enable this by default.

@legrego legrego force-pushed the disallow-code-generation-from-strings branch from d6bc760 to dbab79b Compare February 25, 2026 14:59
@legrego legrego force-pushed the disallow-code-generation-from-strings branch from 7190f4d to 303cce5 Compare April 3, 2026 15:55
Comment thread src/dev/build/tasks/bin/scripts/kibana Outdated
@legrego legrego force-pushed the disallow-code-generation-from-strings branch 2 times, most recently from d58af55 to 8522553 Compare April 7, 2026 18:22
@legrego legrego force-pushed the disallow-code-generation-from-strings branch from 8522553 to 5d9e3f3 Compare April 20, 2026 13:20
@macroscopeapp

This comment was marked as outdated.

@elasticmachine

This comment was marked as outdated.

@legrego legrego force-pushed the disallow-code-generation-from-strings branch 4 times, most recently from 6fcd115 to ab1d9e4 Compare May 21, 2026 20:29
@legrego legrego force-pushed the disallow-code-generation-from-strings branch 4 times, most recently from a8af6de to 7c967ce Compare May 26, 2026 18:53
@legrego legrego added Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Feature:Hardening Harding of Kibana from a security perspective labels May 26, 2026
@legrego legrego force-pushed the disallow-code-generation-from-strings branch 4 times, most recently from 8b8b700 to 2142c93 Compare May 27, 2026 11:37
@github-actions
Copy link
Copy Markdown
Contributor

@legrego, it looks like you're updating the parameters for a rule type!

Please review the guidelines for making additive changes to rule type parameters and determine if your changes require an intermediate release.

@legrego legrego force-pushed the disallow-code-generation-from-strings branch 3 times, most recently from e2f3b5f to 58d230a Compare May 27, 2026 14:26
@legrego legrego force-pushed the disallow-code-generation-from-strings branch 3 times, most recently from 7ec36ff to 4fbe88e Compare May 27, 2026 19:38
legrego added a commit that referenced this pull request May 28, 2026
## Summary

Removes the `js-sha256` dependency in favor of native platform code.

Cherry-picked from the work on
#241162
@legrego legrego force-pushed the disallow-code-generation-from-strings branch from 4fbe88e to 78faaf1 Compare May 28, 2026 12:46
kibanamachine added a commit that referenced this pull request May 28, 2026
# Backport

This will backport the following commits from `main` to `9.4`:
- [Remove js-sha256 dependency
(#271339)](#271339)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Larry
Gregory","email":"larry.gregory@elastic.co"},"sourceCommit":{"committedDate":"2026-05-28T12:32:54Z","message":"Remove
js-sha256 dependency (#271339)\n\n## Summary\n\nRemoves the `js-sha256`
dependency in favor of native platform code.\n\nCherry-picked from the
work
on\nhttps://github.com//pull/241162","sha":"4da84e4e62251e2b133865b703ddc1a79766213b","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","release_note:skip","backport:all-open","dependency-reduction","v9.5.0"],"title":"Remove
js-sha256
dependency","number":271339,"url":"https://github.com/elastic/kibana/pull/271339","mergeCommit":{"message":"Remove
js-sha256 dependency (#271339)\n\n## Summary\n\nRemoves the `js-sha256`
dependency in favor of native platform code.\n\nCherry-picked from the
work
on\nhttps://github.com//pull/241162","sha":"4da84e4e62251e2b133865b703ddc1a79766213b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/271339","number":271339,"mergeCommit":{"message":"Remove
js-sha256 dependency (#271339)\n\n## Summary\n\nRemoves the `js-sha256`
dependency in favor of native platform code.\n\nCherry-picked from the
work
on\nhttps://github.com//pull/241162","sha":"4da84e4e62251e2b133865b703ddc1a79766213b"}}]}]
BACKPORT-->

Co-authored-by: Larry Gregory <larry.gregory@elastic.co>
@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout Lane #42 - serverless-observability_complete / default / local-serverless-observability_complete - Traces in Discover - Explore from APM - Transaction Detail - "Open in Discover" links open traces experience

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test 9 17 +8
@kbn/test-suites-src 56 58 +2
total +10

Total ESLint disabled count

id before after diff
@kbn/test 9 17 +8
@kbn/test-suites-src 61 63 +2
total +10

History

@legrego legrego marked this pull request as ready for review May 28, 2026 17:17
@legrego legrego requested review from a team as code owners May 28, 2026 17:17
@legrego legrego requested a review from azasypkin May 28, 2026 17:17
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/kibana-security (Team:Security)

dej611 pushed a commit to dej611/kibana that referenced this pull request May 29, 2026
## Summary

Removes the `js-sha256` dependency in favor of native platform code.

Cherry-picked from the work on
elastic#241162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Hardening Harding of Kibana from a security perspective release_note:skip Skip the PR/issue when compiling release notes Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants