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

ELインジェクション対策としてJEXL 3.4へアップデート #128

Merged
merged 10 commits into from
Dec 14, 2024

Conversation

mygreen
Copy link
Owner

@mygreen mygreen commented May 19, 2024

修正内容

Commons JEXL を2.1 ⇒ 3.4へアップデート。

  • EL Injection として、任意のプログラムが実行可能なため、対策として、JEXL 3.3から導入された JexlPermissions によるEL式中で実行/参照可能なクラスなどを制限するようにした。
    • XlsMapperは、パッケージ com.gh.mygreen.xlsmapper.* 以下全てを許可する指定。
    • 独自のCellConverter / FiledProcessosrを使うときは、システムプロパティ xlsmapper.jexlPermissions でカンマ区切りで指定する。
    • システムプロパティ xlsmapper.jexlRestricted=false でパーミッションによる制限をOFFに切り替え可能。
  • EL式中の独自のカスタム関数の登録処理を ExpressionLanguageJEXLImpl.java に集約。
  • 式言語の接頭語を x:f: に変更し、エラーメッセージの f: に統一。
    • 数式を指定するアノテーション @XlsFormula の属性 value 内で使用可能な予め登録されている関数の接頭語に影響がある。
  • 不要となった式言語のパース結果のキャッシュ用オブジェクト ObjectCache を削除。
    • JexlEngineのキャッシュ機能を使用するように変更したため不要となった。
  • MessageInterpolatorにおいて、EL式/変数のときに再帰評価を削除し、EL Injectionの起点となっていたのを除去。
    • メッセージプロパティの場合も再帰評価回数の最大回数を指定し、無限ループを回避。
  • CsvBeanValidation による BeanValidation のエラーメッセージの処理方法を変更。
    • アノテーションの属性 message でデフォルトのエラーメッセージ指定して、デフォルト値から変更されていた場合、評価前のテンプレートの状態で渡すように変更し、CsvContextの情報を評価可能にすにする。

特記事項

  • JEXL v3.4が最新版だが、POI v5.1の依存関係のcommons-loggingのバージョン関係が悪く実行時エラーが出るため、JEXL v3.4の依存関係からcommons-loggingを除外。
    • POI v5.2であれば問題なかった。

@mygreen mygreen added enhancement dependencies Pull requests that update a dependency file labels May 19, 2024
@mygreen mygreen force-pushed the topic/update_jexl branch from 2251bc1 to 370912e Compare June 29, 2024 01:51
@mygreen mygreen changed the title ELインジェクション対策としてJEXL 3.3へアップデート ELインジェクション対策としてJEXL 3.4へアップデート Jun 29, 2024
@mygreen mygreen force-pushed the topic/update_jexl branch from 370912e to 893fb82 Compare June 29, 2024 02:12
@mygreen mygreen changed the title ELインジェクション対策としてJEXL 3.4へアップデート ELインジェクション対策としてJEXL 3.3へアップデート Jun 29, 2024
@mygreen mygreen changed the base branch from master to develop/2.3 July 20, 2024 01:48
mygreen added 2 commits July 20, 2024 11:09
・カスタム関数の定義個所を式言語の実装個所に集約。
・式言語の接頭語をx:⇒f:に変更
@mygreen mygreen force-pushed the topic/update_jexl branch from 893fb82 to d4f6ac9 Compare July 20, 2024 02:10
@mygreen mygreen changed the title ELインジェクション対策としてJEXL 3.3へアップデート ELインジェクション対策としてJEXL 3.4へアップデート Jul 20, 2024
@mygreen mygreen added this to the 2.3 milestone Dec 14, 2024
@mygreen mygreen merged commit 230a924 into develop/2.3 Dec 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant