You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Node.js Permission Model is a mechanism for restricting access to specific resources during execution. The API exists behind a flag --permission which when enabled, will restrict access to all available permissions.
When starting Node.js with --permission, the ability to access the file system through the fs module, spawn processes, use node:worker_threads, use native addons, use WASI, and enable the runtime inspector will be restricted.
Regression Issue
Select this option if this issue appears to be a regression.
SDK version number
All
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
>=22.13.0
Reproduction Steps
Pass credentials during client creation, and make any API call
Example code which creates DynamoDB client, and calls listTable API.
Call the sample code with node@>=22.13.0 and pass --permission
Observed Behavior
$ node --permission test.mjsnode:internal/fs/promises:639 binding.openFileHandle(path, flagsNumber, mode, kUsePromises), ^Error: Access to this API has been restricted at open (node:internal/fs/promises:639:13) at readFile (node:internal/fs/promises:1242:20) at getSource (node:internal/modules/esm/load:42:20) at defaultLoad (node:internal/modules/esm/load:114:40) at ModuleLoader.load (node:internal/modules/esm/loader:670:12) at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:483:43) at #createModuleJob (node:internal/modules/esm/loader:507:36) at #getJobFromResolveResult (node:internal/modules/esm/loader:275:34) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:243:41) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:546:25) { code: 'ERR_ACCESS_DENIED', permission: 'FileSystemRead', resource: '/Users/trivikr/workspace/test/test.mjs'}Node.js v22.13.0
After some investigation, we concluded that this is working as intended.
For filesystem read permission, we need to at least grant it on the files being executed. In the case of this test, it would be the test file and any node_modules being loaded like the SDK. We exclude the ~/.aws/config and credentials files.
# include fs read permission on the file being run and the local node_modules
node --permission --allow-fs-read="./*" ./listTables.mjs
This results in CredentialsProviderError: Could not load credentials from any providers, because my test environment is normally resolved to credentials from file. This behavior is consistent and equivalent with the files not being present, meaning no additional handling is needed at this time by the SDK or Smithy core.
After supplying ENV level credentials, the SDK request works as expected.
kuhe
changed the title
SDK should not access file system if credentials are provided
SDK interaction with Node.js v22.13.0+ permission model
Jan 9, 2025
kuhe
added
guidance
General information and guidance, answers to FAQs, or recommended best practices/resources.
and removed
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Jan 9, 2025
Applications usually have multiple files present outside of node_modules, so providing access to current folder is recommended as mentioned in previous example.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
SDK should not access file system if credentials are provided
The permission model got stable in [email protected].
The Node.js Permission Model is a mechanism for restricting access to specific resources during execution. The API exists behind a flag --permission which when enabled, will restrict access to all available permissions.
When starting Node.js with
--permission
, the ability to access the file system through the fs module, spawn processes, use node:worker_threads, use native addons, use WASI, and enable the runtime inspector will be restricted.Regression Issue
SDK version number
All
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
>=22.13.0
Reproduction Steps
Pass credentials during client creation, and make any API call
Example code which creates DynamoDB client, and calls listTable API.
Call the sample code with
node@>=22.13.0
and pass--permission
Observed Behavior
Expected Behavior
Call to return data
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: