Skip to content

status: verify TLS on the check.torproject.org request#200

Open
UncleJ4ck wants to merge 1 commit into
htrgouvea:developfrom
UncleJ4ck:fix/status-tls
Open

status: verify TLS on the check.torproject.org request#200
UncleJ4ck wants to merge 1 commit into
htrgouvea:developfrom
UncleJ4ck:fix/status-tls

Conversation

@UncleJ4ck

Copy link
Copy Markdown

What was a problem?

HTTP::Tiny->new defaults to verify_SSL => 0, so the status check accepted any certificate. A tor exit, or anyone on the path, could return a forged {"IsTor":true} and nipe would report you as protected when you were not.

How this PR fixes the problem?

Turn on verify_SSL for the check.torproject.org request. IO::Socket::SSL is already a declared dependency. The response formatting is split into a pure format_status so the output contract is testable without a network call.

Check lists (check x in [ ] of list items)

  • Test passed
  • Coding style (indentation, etc)

Additional Comments (if any)

t/30-status.t covers the tor, non-tor and error branches.

Comment thread lib/Nipe/Component/Utils/Status.pm Outdated
sub new {
my $api_check = 'https://check.torproject.org/api/ip';
my $request = HTTP::Tiny -> new -> get($api_check);
# Pure formatter, separated from the network call so the output contract can

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove comments

Comment thread lib/Nipe/Component/Utils/Status.pm Outdated
# Pure formatter, separated from the network call so the output contract can
# be unit tested. $data is the decoded check.torproject.org payload, or undef
# when the request failed.
sub format_status {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

don't create new sub routines

Comment thread lib/Nipe/Component/Utils/Status.pm Outdated

if ($request -> {status} == $SUCCESS_CODE) {
my $data = decode_json($request -> {content});
my $check_ip = $data->{'IP'};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

you need to follow the style guide

@UncleJ4ck

UncleJ4ck commented Jun 11, 2026

Copy link
Copy Markdown
Author

done. comments gone, no extra subroutine, just the verify_SSL flag on the request. test under tests/ mocks HTTP::Tiny.

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.

2 participants