Skip to content

Undefined behaviour when piping #139

@tegefaulkes

Description

@tegefaulkes

Describe the bug

So it's possible to use the pipe operation to input into a polykey command. For example, echo password | npm run polykey -- agent start. This will actually input the password on the first prompt.

// Start an agent normally
brian@matrix-precision-3480-syzygy:~/workspace/Polykey-CLI/ > npm run polykey -- agent start -np ./tmp/test1 

> [email protected] polykey
> ts-node src/polykey.ts agent start -np ./tmp/test1

✔ Enter new password … ******** // Password entered manually
✔ Confirm new password … ********
(node:1189978) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
pid             1189978
nodeId          v9q4nj2j4sqipj9nlm197fsfofvn61pcvghreml5cjpiv748o6960
clientHost      ::1
clientPort      43369
agentHost       ::
agentPort       41059
recoveryCode    celery grit genre truly weapon tilt cause plug donate forward tackle junior sphere cave sun cloth assist catalog risk bomb staff rate goddess poverty
^C

// With state created we run again while piping in the password
brian@matrix-precision-3480-syzygy:~/workspace/Polykey-CLI/ > echo "password" | npm run polykey -- agent start -np ./tmp/test1

> [email protected] polykey
> ts-node src/polykey.ts agent start -np ./tmp/test1

✔ Please enter the password … ******** // Password is provided by the pipe
(node:1190120) [DEP0112] DeprecationWarning: Socket.prototype._handle is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
pid             1190120
nodeId          v9q4nj2j4sqipj9nlm197fsfofvn61pcvghreml5cjpiv748o6960
clientHost      ::1
clientPort      46567
agentHost       ::
agentPort       37515
^C

If we try and start Polykey using a pipe and starting from scratch we end up with a promise deadlock.

brian@matrix-precision-3480-syzygy:~/workspace/Polykey-CLI/ > echo "password" | npm run polykey -- agent start -np ./tmp/test3

> [email protected] polykey
> ts-node src/polykey.ts agent start -np ./tmp/test3

✔ Enter new password … ********
? Confirm new password › ErrorPolykeyCLIAsynchronousDeadlock

Trying with a newline has the same problem

brian@matrix-precision-3480-syzygy:~/workspace/Polykey-CLI/ > echo "password\npassword" | npm run polykey -- agent start -np ./tmp/test3

> [email protected] polykey
> ts-node src/polykey.ts agent start -np ./tmp/test3

✔ Enter new password … ****************

? Confirm new password › ErrorPolykeyCLIAsynchronousDeadlock

My guess is that the pipe closing is causing the problem here.

To Reproduce

  1. start polykey with echo password | agent start from fresh state
  2. polykey shold throw an ErrorPolykeyCLIAsynchronousDeadlock error.

Expected behavior

Hard to say, maybe it should input the first password no problem, but still wait for the confirmation input? Is it also possible to include newlines in the password like this? Do we want to support that? Do we need to sanitise password inputs?

Platform (please complete the following information)

  • Device: precision laptop
  • OS: nixos
  • Version 23

Notify maintainers

@tegefaulkes

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingr&d:polykey:core activity 1Secret Vault Sharing and Secret History Management

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions