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

[Mac Sonoma] "WARNING: Secure coding is not enabled for restorable state" warning message #630

Open
Phillipus opened this issue May 14, 2024 · 8 comments

Comments

@Phillipus
Copy link

The issue
When running Eclipse or an RCP app on macOS Sonoma a warning message is written to the console:

eclipse[4647:170325] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.

I've Googled this and it seems that this could lead to a vulnerabilty and needs to be addressed. For example see here:

https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate?rq=2

To Reproduce
The only way to see this warning message is to run Eclipse on Mac Sonoma from the command line so the message is written to the console in the Terminal app:

  1. Open the Mac Terminal app and run the following command:
    Eclipse.app/Contents/MacOS/eclipse
  2. The warning message is written to the terminal window

Expected behavior
The warning message should not appear.

Environment:
macOS Sonoma 14.5
MacBook M2 aarch64
Temurin JDK 17.0.11+9
Eclipse 4.31 and latest 4.32 I builds

@Phillipus
Copy link
Author

Phillipus commented May 14, 2024

The warning message first appears at this point:

And so, if it is possible to implement this, it will be in the native JNI code here:

https://github.com/eclipse-equinox/equinox/tree/master/features/org.eclipse.equinox.executable.feature/library/cocoa

Where is the main NSApplication and NSApplicationDelegate created? Is it here? And, if so, can applicationSupportsSecureRestorableState be implemented to return true?

@Phillipus
Copy link
Author

Phillipus commented May 14, 2024

I first reported this issue in the SWT issue tracker, and then closed that one and opened it here because the warning message appearing at the bridge.showSplash point. But after debugging with the -noSplash option the warning message now appears immediately after this line in WorkbenchAdvisor:

https://github.com/eclipse-platform/eclipse.platform.ui/blob/deb75d4e977d767d3c5249e8a953fd2ef986baab/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/application/WorkbenchAdvisor.java#L768

So I'm not sure whether to continue to trace this to SWT or Equinox. Or maybe both? Need to find out where the NSApplication and NSApplicationDelegate are created.

@HannesWell @HeikoKlare WDYT?

@mdaloia
Copy link
Contributor

mdaloia commented May 14, 2024

This JDK issue could be related: https://bugs.openjdk.org/browse/JDK-8318854

@Phillipus
Copy link
Author

Phillipus commented May 14, 2024

This JDK issue could be related: https://bugs.openjdk.org/browse/JDK-8318854

Yes, thanks for the link. They've implemented applicationSupportsSecureRestorableState in their NSApplicationDelegate for AWT.

I've been trying to figure out how to do the same in SWT. So far I've found some clues in the Display class with no success at a solution:

https://github.com/eclipse-platform/eclipse.platform.swt/blob/d3df7965e5c37d6514182929022e2d82139b919a/bundles/org.eclipse.swt/Eclipse%20SWT/cocoa/org/eclipse/swt/widgets/Display.java#L1035-L1056

I can add a applicationSupportsSecureRestorableState method and selector but don't know where it can implemented to return a boolean.

@HannesWell
Copy link
Member

So I'm not sure whether to continue to trace this to SWT or Equinox. Or maybe both? Need to find out where the NSApplication and NSApplicationDelegate are created.

@HannesWell @HeikoKlare WDYT?

I'm sorry, but I can't help much on this: I have only little knowledge about the C code itself and zero knowledge about Mac their API.
Maybe @sravanlakkimsetti or @lshanmug can help?

@HeikoKlare
Copy link
Contributor

So I'm not sure whether to continue to trace this to SWT or Equinox. Or maybe both? Need to find out where the NSApplication and NSApplicationDelegate are created.
HannesWell HeikoKlare WDYT?

I'm sorry, but I can't help much on this: I have only little knowledge about the C code itself and zero knowledge about Mac their API. Maybe sravanlakkimsetti or lshanmug can help?

I am sorry, but unfortunately the same holds for me. I use a Mac only for validation purposes and for migrating changes I make for one OS (in particular Windows) to the others, but I have no knowledge about the system's APIs, the native SWT code etc.

Just from what I have seen so far, I would expect that SWT code is responsible for NSApplication and NSApplicationDelegate, but that's only a guess.

Phillipus added a commit to Phillipus/eclipse.platform.swt that referenced this issue May 15, 2024
- See eclipse-platform#1228

- On macOS 14 and later a warning message is written to console:

"WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES."

- As recommended by Apple, this change adds a new selector for applicationSupportsSecureRestorableState and returns a 1 value (YES) in the callback in the Display class

- However, this only takes care of the NSApplicationDelegate created in the Display class. The warning message will still appear when a splash screen is created in Equinox JNI code so a fix there is also required. See eclipse-equinox/equinox#630

- This implementation for SWT can be tested by using the -noSplash argument when launching Eclipse
@Phillipus
Copy link
Author

Phillipus commented May 15, 2024

It turns out that this warning message is triggered in two places - SWT and Equinox. Both use a NSApplication and so both need to implement applicationSupportsSecureRestorableState in the delegate.

I've fixed the SWT case here but I can't fix the issue in the JNI code. I think this file needs to change.

@Phillipus
Copy link
Author

Phillipus commented May 15, 2024

PR - #632

Phillipus added a commit to Phillipus/equinox that referenced this issue May 15, 2024
- See eclipse-equinox#630

- On macOS 14 and later a warning message is written to console:
"WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES."

- This adds an NSApplicationDelegate that implements applicationSupportsSecureRestorableState
lshanmug pushed a commit to eclipse-platform/eclipse.platform.swt that referenced this issue May 20, 2024
- See #1228

- On macOS 14 and later a warning message is written to console:

"WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES."

- As recommended by Apple, this change adds a new selector for applicationSupportsSecureRestorableState and returns a 1 value (YES) in the callback in the Display class

- However, this only takes care of the NSApplicationDelegate created in the Display class. The warning message will still appear when a splash screen is created in Equinox JNI code so a fix there is also required. See eclipse-equinox/equinox#630

- This implementation for SWT can be tested by using the -noSplash argument when launching Eclipse
amartya4256 pushed a commit to amartya4256/eclipse.platform.swt that referenced this issue Jun 6, 2024
…latform#1231)

- See eclipse-platform#1228

- On macOS 14 and later a warning message is written to console:

"WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES."

- As recommended by Apple, this change adds a new selector for applicationSupportsSecureRestorableState and returns a 1 value (YES) in the callback in the Display class

- However, this only takes care of the NSApplicationDelegate created in the Display class. The warning message will still appear when a splash screen is created in Equinox JNI code so a fix there is also required. See eclipse-equinox/equinox#630

- This implementation for SWT can be tested by using the -noSplash argument when launching Eclipse
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

No branches or pull requests

4 participants