Skip to content

Conversation

@victorlpgazolli
Copy link
Contributor

@victorlpgazolli victorlpgazolli commented May 23, 2022

Summary:

I've been curious about how rn cli handle app in debug mode interactions with IDE,
I know that when you get some error in your app (e.g crash) when you are coding, you get an error message saying what line broke.. And that got me thinking.. how can the app open my IDE? and I came across this endpoint from cli package cli-server-api:

POST /open-url

In first sight i assumed it was HTTP and HTTPS only, but its not, turns out you can open any uri scheme.

To put this in perspective, if you have the cli-server-api running and someone inside your network wants your pc to open any uri scheme, they can though this endpoint. Especial thanks to @R3tr074 for investigating it further (poc)

POC:

curl --request POST \
  --url http://localhost:8081/open-url \
  --header 'Content-Type: application/json' \
  --data '{"url": "file:///etc/hosts"}'

Other uri schemes:
image
I've tested on linux and macOs, linux depends on how you set up your xdg-open config, and macOs uses the default open command;

You can see what uri schemes are available on MacOs using this command
lsregister -dump URLSchemeBinding;

# lsregister is available at: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister

Test Plan:

I tested it with react-native change locally, and linking with my projects as previously recommended in contributing guide

Result:
image

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I left a small feedback but it seems correct in general

@victorlpgazolli victorlpgazolli requested a review from thymikee May 25, 2022 00:59
@victorlpgazolli
Copy link
Contributor Author

victorlpgazolli commented May 25, 2022

Thanks! I left a small feedback but it seems correct in general

Thanks @thymikee ! i've changed as requested ;)

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@thymikee
Copy link
Member

Would you mind running yarn lint --fix to correct linting issues?

@thymikee thymikee merged commit a87fb90 into react-native-community:master May 25, 2022
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

Successfully merging this pull request may close these issues.

3 participants