iri icon indicating copy to clipboard operation
iri copied to clipboard

--remote-limit-api also filters local calls

Open ghost opened this issue 9 years ago • 24 comments

When IRI v 1.1.2.4 is started with the --remote-limit-api command line parameter, the commands are also being blocked even if the call comes form the local loopback interface:

"COMMAND getNeighbors is not available on this node" is received when an explicit call is made to http://127.0.0.1:14265 The same behaviour happens if IPv6 is used http://[::1]:14265 or the usual moniker http://localhost:14265

The command filter should block access only to those requests coming from non-node ip addresses, right?

This could be OS-specific behaviour, as I only have tested it Windows. IRI was directly compiled from source using maven 3.3.9 and JDK 1.8.121

ghost avatar Jan 22 '17 16:01 ghost

image

Example of output using unmodified console.html on Chrome running on the node

ghost avatar Jan 22 '17 16:01 ghost

Just to make sure, here's the initiating command line: java -jar iri-1.1.2.4.jar -p 14265 -r 14265 --remote-limit-api "addNeighbors, removeNeighbors, getNeighbors, interruptAttachingToTangle, attachTotangle" --remote -e -n "....."

ghost avatar Jan 22 '17 16:01 ghost

I can Confirm that this issue is not Windows specific. I experience the same problem on Ubuntu 16.04

bahamapascal avatar Jan 22 '17 17:01 bahamapascal

Try with this branch: https://github.com/iotaledger/iri/tree/fixRemoteApiLimit

paulhandy avatar Jan 23 '17 21:01 paulhandy

Solved in https://github.com/iotaledger/iri/commit/c8a0d942be90eeb067edbbe00b878bc25a10d63b

paulhandy avatar Jan 23 '17 22:01 paulhandy

Test with self-compiled jar and with jar provided by Paul, the issue remains, at least in Windows Going to test further to make sure I'm not forgetting anything, but after testing with that last jar that was supplied, I'm pretty sure the issue is not solved in this situation

ghost avatar Jan 23 '17 23:01 ghost

@project-Shift please provide the startup command you are using, as well as what API calls you are attempting, if they are different from above.

paulhandy avatar Jan 23 '17 23:01 paulhandy

no, same startup as above; several tests again, all the outcomes are the same, call is blocked.

ghost avatar Jan 23 '17 23:01 ghost

I tested on Ubuntu 16.04 and successfully passed the getNeighbors API via localhost while remote call was blocked. Did not test on windows though

bahamapascal avatar Jan 23 '17 23:01 bahamapascal

Also, I looked at you code, and although I'm not a dev, and don't know java, I would like to point out that in line 119, you might have used the actual loopback address instead of the "localhost" var !sourceAddress.getAddress().equals(InetAddress.getByName("localhost"))) transforms into !sourceAddress.getAddress().equals("127.0.0.1")) , at least just to diagnoze the fix?

The reason is simple: IPv6 , that happens to be active in my windows node Localhost resolves to IPv6 loopback, which is [::1] , so I'm not sure how that comparison will work.

My humble apologies if it's a stupid suggestion, just trying to help out, even though clueless ...

ghost avatar Jan 23 '17 23:01 ghost

Mean while, I'll try with IPv6 off ...

ghost avatar Jan 23 '17 23:01 ghost

could you try tossing System.out.format("source:%s\tlocalhost:%s",sourceAddress.getAddress().toString(), InetAddress.getByName("localhost").toString()); in line 118, and print out what the console debugger gives?

paulhandy avatar Jan 23 '17 23:01 paulhandy

ups, not sure I quite follow those instructions :-/ Where and how should I do that?

ghost avatar Jan 23 '17 23:01 ghost

Actually, try replacing

 !sourceAddress.getAddress().equals(InetAddress.getByName("localhost")))

with the following:

                    !sourceAddress.getAddress().equals(InetAddress.getLocalHost()))

paulhandy avatar Jan 23 '17 23:01 paulhandy

to the best of my current skill set, I looked up the api.java file in src, altered line 118 as per your request, did a new compile and packaging, replaced iri ... and the result is the same.

But these are uncharted waters for me! first time ever editing Java and 3th time only compiling ... so thread carefully :-D

ghost avatar Jan 24 '17 00:01 ghost

thread carefully

I see what you did there.

paulhandy avatar Jan 24 '17 00:01 paulhandy

I did that on my local node, ofc, not on git

ghost avatar Jan 24 '17 00:01 ghost

btw, also tried my stupid suggestion with the same results, so ...

ghost avatar Jan 24 '17 00:01 ghost

What's in C:\WINDOWS\system32\drivers\etc\hosts?

paulhandy avatar Jan 24 '17 00:01 paulhandy

definitely related to IPv6, it seems I introduced sourceAddress.getAddress() and InetAddress.getByName("localhost") in the returned console message, to see what it was reading, and this is the result: sourceAddress.getAddress() = 0:0:0:0:0:0:0:1 <--- IPv6 loopback !!! InetAddress.getByName("localhost") = localhost/127.0.0.1

I suposedly already disabled IPv6 in this node, but since it's a core version, I might be missing something. Either way, this might explain why it's failing on my windows system

ghost avatar Jan 24 '17 00:01 ghost