Bitcoin Forum
May 07, 2024, 02:21:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they believe that the creator of this topic displays some red flags which make them high-risk. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
Author Topic: Nxt source code flaw reports  (Read 113306 times)
gsan1
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 06, 2014, 12:49:44 PM
 #501

hmpf....so I misunderstood the phrase "3 flaws were injected into 0.4.7e".

0.4.7e source code was modified before publishing.

Huh The binary of 0.4.7e that was published weeks ago and used in production does not contain the flaws we are searching here, right? Otherwise that would mean, that we used software that has critical flaws in it. The binary 0.5.0 should have these flaws fixed to, right? Otherwise someone could exploit them, when they are known in this topic.

The source code of 0.4.7e that was published on 3. January is the version of binary 0.4.7e minus alias, coloured coins plus three security flaws. Right? So why can't you confirm that the flaws we are searching are fixed in 0.4.7e or 0.5.0?
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715091710
Hero Member
*
Offline Offline

Posts: 1715091710

View Profile Personal Message (Offline)

Ignore
1715091710
Reply with quote  #2

1715091710
Report to moderator
ferment
Full Member
***
Offline Offline

Activity: 168
Merit: 100


IDEX - LIVE Real-time DEX


View Profile
January 06, 2014, 12:53:24 PM
 #502

hmpf....so I misunderstood the phrase "3 flaws were injected into 0.4.7e".

0.4.7e source code was modified before publishing.

The source code of 0.4.7e that was published on 3. January is the version of binary 0.4.7e minus alias, coloured coins plus three security flaws. Right? So why can't you confirm that the flaws we are searching are fixed in 0.4.7e or 0.5.0?

To get the published code:

1. Remove advanced stuff (aliases, etc) from 0.4.7e.
2. Inject 3 logic flaws.
3. Post on bitbucket.

The code for 0.5.0 never saw the flaws.

ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 12:54:41 PM
 #503

So why can't you confirm that the flaws we are searching are fixed in 0.4.7e or 0.5.0?
There was no flaws we are looking for. They were introduced in source code with purpose.
gsan1
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 06, 2014, 12:59:18 PM
 #504

To get the published code:

1. Remove advanced stuff (aliases, etc) from 0.4.7e.
2. Inject 3 logic flaws.
3. Post on bitbucket.

The code for 0.5.0 never saw the flaws.

But this is a condradiction to CfBs statement?

Yes, logical flaws. But if I understand CfB correct, he states that the original 0.4.7e (the version which was distributed to the nxt users) and subsequent versions do NOT contain those logical flaws. Can you confirm that, CfB?

No, I can't.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 12:59:43 PM
 #505

So since my local 0.5.0 clients started crashing (i.e. showing negative recent blocks numbers, etc.) I started analyzing a little...
I started by getting the blocks that it currently knows from the api...
The block ids from the top of the list were:
16120160395225814370
17250788183583576225
11124825242748196662
14790117364446866715
8810693157391937532

So according to the block explorer, my top 4 blocks are from a forked chain. Nothing tragic, happens...
Let's look at the cumulative difficulty:
my client says 877033680606371.
Let's check some other node in the network, take node10.nxtbase.com, and we get: 877619990555689

So why doesn't my client catch up?
Let's have a look with wireshark, what's going on...
The first thing that we see is... ehm... 192.161.48.32, aka node00.nxtbase.org.
This node is spamming me with all kinds of slightly weird stuff, e.g. duplicate acks.
Ok, whatever, let's look at our stuff...
My client seems to only do Post requests to one single address... 192.161.48.32 WTF?!?
The address answers fast with a nice cumulative difficulty of 866067307974274.
Wait a sec... that's quite low? What's going on there? Well, later...
First: Why the hell am I only asking that weird address???
Let's see whom I'm connected to. getPeers from my account and for each of them getPeer and look for connected:1, because only from them I will query new blocks.
There are 10 of them, one is node00.nxtbase.org, the other 9 look a bit more legit... but wait!
All of those 9 have a negative weight... doesn't that? Yes, yes, it does... If a node's weight is negative, it isn't considered for blockchain scanning. Ok, but then, why isn't it connecting to other nodes?
Well, it only connects to other nodes if it isn't connected to 10 nodes already... And why does it keep the connection to nodes with a negative weight? I don't know... Really, why don't you cancel connections to nodes that you'll never use???
Anyways... How did the weight become negative?
Let's start by looking at peer.weight... This is set in analyze hallmark, and only there... and before it is set, it's checked whether it is smaller than 0... WTF?!? Ah! getWeight() is not a getter for weight... well, obviously, why would I expect any senseful naming from that code! Thanks for taking my time looking into the wrong direction, again. (shift+alt+r getBalanceAdjustedWeight) [for those, that don't know eclipse: i just renamed all occurrences of getWeight with getBalanceAdjustedWeight, what it really is, so I won't be confused by that in the future... Why CfB and others didn't do that? IDK.]
But on that topic, I also saw an updateWeight... hmm, is that going to update the weight or the adjustedWeight? Well, neither, it doesn't take a parameter and it sends a processNewData request to all Users... Guys, seriously?!? MVC - Model, View, Controller, not Mix Various Crap :p
Back to our attacker, or the weight, or sth...
How can it be negative?
Well, it calculates the following: adjustedWeight * (account.getBalanceCent() / 100) / 1000000000 [I added Cent to the functions that return amount in 0.01 NXT, because some did, some didn't]
adjustedWeight is calculated whenever a new hallmark is analyzed and it is basically just the fraction of this peer's weight within all peer's weight, nothing that could be negative.
But the balance might be... at least I know one account off the top of my head that has a negative balance, the genesis account.
So let's take a node with a negative balance and look at the account.
Randomness has chosen: node81.nxtbase.com with a current weight of -25046. So which account does it have?
Well, the account ID are the first 32 bytes of the hallmark, well , actually the last 32, but let's not go into that topic...
Anyway, the accountID is 11243542237777034551, so it's not the genesis account and it should have a balance of around 315k according to the block explorer. So what does my client say?
Well, it's not that easy. Unfortunately we can't query an account's balance with any API call... bummer.
So let's look at the transactions instead... All of them have a lot of confirmations, so just accumulate them, subtract the fees for sent transactions... aaaand... 315402... looks legit, definitely not negative.
So what happent to Account.balance?
Let's look at where that is set. We've got a total of 6 occurrences...
When we analyze a block:
- the generator account is credited with the fee. (Let's hope noone gets credited more than once)
- for every transaction, the sender account gets the transaction amount and fee deducted (the sender account is expected to already exist, let's hope that's always the case and doesn't crash with a NullPointer because then the recipients wouldn't get their balance updated)
- for every transaction, the recipient is credited with the transaction amount
When we popLastBlock:
Same procedure, just all the + are now -. Say something about duplicate code, but hey...

Ok, so far so good, let's go deeper Smiley
Let's change the order of things and first look at where popLastblock is called... because that gets only called once. Wink
It's called when we're getting a block chain, in case the last common block of us and the peer is not either of our last blocks, i.e. there has been a fork. Should happen regularly, right?
So what do we do in that case?
We write blocks and transactions to a backup file, then we pop our blocks until we find the common ancestor, then we push the peers blocks, and then we check if the cumulative difficulty really has increased, as promised earlier by the peer.
So what happens, if the peer lied about the cumulative difficulty and just sent us a few (say 2) blocks, branched from very far (say 700) blocks back?
We'll pop 700 blocks, push 2 blocks, realize that we got bulls^&t, blacklist the peer and load our backups. And then everything is fine, isn't it? ISN'T IT?
No, it's not.
While popping the 700 blocks, we adjusted the balance of all accounts to the state 700 blocks ago. Then when pushing the 2 blocks, we took whatever transactions the "intruder" wanted us to know and included into his blocks, and adjust our account's balances accordingly.
And when we realize, everything was crap? Do we reset the accounts to what they were before? No, we don't. We keep the crap balances and hope for the best.

So if you want to take down a client, that is *any client*, just analyze the hall marks in the network, wait for some nice transactions, and generate a few blocks where you may or may not include the transactions to set the balance to a negative value which then causes the attacked client to not talk to that part of the network anymore and the *validation of new blocks to also be corrupted*, which enables you to send some nicely crafted blocks that only the attacked clients will accept and strengthen your position as the only peer it wants to communicate with.

So is that the injected flaw to take down a forked currency within a day? If yes, why does it work in 0.5.0? ^^

(Btw: Only posting this publicly because it is already widely used)


[edit]
Totally forgot: Kudos to whoever attacked using that way, nice find. Smiley

This is a serious bug and is worth a reward. Thank u.

PS: This is not an injected flaw.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:02:53 PM
 #506

No. It's just 264.

Was my previous question EVEN MORE trivial for you to not even bother?   Cheesy

Maybe...
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 01:03:29 PM
 #507

PS: This is not an injected flaw.
It's time to post this:
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:04:46 PM
 #508

Huh The binary of 0.4.7e that was published weeks ago and used in production does not contain the flaws we are searching here, right? Otherwise that would mean, that we used software that has critical flaws in it. The binary 0.5.0 should have these flaws fixed to, right? Otherwise someone could exploit them, when they are known in this topic.

The source code of 0.4.7e that was published on 3. January is the version of binary 0.4.7e minus alias, coloured coins plus three security flaws. Right? So why can't you confirm that the flaws we are searching are fixed in 0.4.7e or 0.5.0?

If I answered that would be too easy, keep digging. Grin
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:06:11 PM
 #509

To get the published code:

1. Remove advanced stuff (aliases, etc) from 0.4.7e.
2. Inject 3 logic flaws.
3. Post on bitbucket.

The code for 0.5.0 never saw the flaws.

But this is a condradiction to CfBs statement?

Yes, logical flaws. But if I understand CfB correct, he states that the original 0.4.7e (the version which was distributed to the nxt users) and subsequent versions do NOT contain those logical flaws. Can you confirm that, CfB?

No, I can't.

There is no contradiction. I just can't confirm this due to the rules of the review.
ferment
Full Member
***
Offline Offline

Activity: 168
Merit: 100


IDEX - LIVE Real-time DEX


View Profile
January 06, 2014, 01:06:17 PM
 #510

Well, it's not that easy. Unfortunately we can't query an account's balance with any API call... bummer.
Great debugging!

FYI... there is an api.

http://localhost:7874/nxt?requestType=getBalance&account=11243542237777034551

ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 06, 2014, 01:08:01 PM
 #511

This is a serious bug and is worth a reward. Thank u.

PS: This is not an injected flaw.

Can we please get a 0.5.1 fast that does a quick fix for that? I'm tired of restarting my client all the time. :p

[edit]
damn th 360s post limit...
Well, it's not that easy. Unfortunately we can't query an account's balance with any API call... bummer.
Great debugging!

FYI... there is an api.

http://localhost:7874/nxt?requestType=getBalance

Oah, I missed an API... damn it... but anyways, here's the result, confirming my finding: Cool
{"balance":-31542200,"effectiveBalance":-31542200,"unconfirmedBalance":-31542200}
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:09:08 PM
 #512

This is a serious bug and is worth a reward. Thank u.

PS: This is not an injected flaw.

Can we please get a 0.5.1 fast that does a quick fix for that? I'm tired of restarting my client all the time. :p

This is not a critical bug, so it's better to stick to the plan, IMHO.
ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 06, 2014, 01:14:30 PM
 #513

This is a serious bug and is worth a reward. Thank u.

PS: This is not an injected flaw.

Can we please get a 0.5.1 fast that does a quick fix for that? I'm tired of restarting my client all the time. :p

This is not a critical bug, so it's better to stick to the plan, IMHO.
Are you kidding me??? This bug is used in the wild and is crashing your clients left and right! Mine has been crashed using that method 4 times in the last 24h, others too.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:15:00 PM
 #514

Are you kidding me??? This bug is used in the wild and is crashing your clients left and right! Mine has been crashed using that method 4 times in the last 24h, others too.

This happens only when u connect to a rogue node, most of the nodes r legit ones. NRS has been working with this bug since genesis block. Why is it critical?
bidji29
Sr. Member
****
Offline Offline

Activity: 392
Merit: 250


View Profile
January 06, 2014, 01:15:55 PM
 #515

I sent you another donation ricot for your amazing work

http://www.freebieservers.com/  100% FREE GAME SERVERS
nexern
Hero Member
*****
Offline Offline

Activity: 597
Merit: 500



View Profile
January 06, 2014, 01:40:13 PM
 #516

I sent you another donation ricot for your amazing work

+1
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 06, 2014, 01:44:12 PM
 #517

I sent you another donation ricot for your amazing work

+1

We need guys like him in our team. Hey, big stakeholders, do u hear me?
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 01:51:54 PM
 #518

We need guys like him in our team. Hey, big stakeholders, do u hear me?
Definitely. ricot found most interesting flaws in last days, not a small local mistakes, but broken logic in execution flow.

Btw, did you miss my observation in shadows of big ricot investigation? Smiley Any comment, please...
ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 06, 2014, 02:14:54 PM
 #519

We need guys like him in our team. Hey, big stakeholders, do u hear me?
Definitely. ricot found most interesting flaws in last days, not a small local mistakes, but broken logic in execution flow.

Btw, did you miss my observation in shadows of big ricot investigation? Smiley Any comment, please...
I also had a quick look at yours: The actual adding of the blcok in pushBlock is synchronized on blocks, so any processBlock call would wait there until the blockchain loading request is finished. (since that synchronizes before doing the popping)
It may however, ignore the block that has been sent using processBlock, eventhough it would have been valid.
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 06, 2014, 02:24:21 PM
 #520

I also had a quick look at yours: The actual adding of the blcok in pushBlock is synchronized on blocks, so any processBlock call would wait there until the blockchain loading request is finished. (since that synchronizes before doing the popping)
It may however, ignore the block that has been sent using processBlock, eventhough it would have been valid.
1. pushBlock() is not sync'ed outside, in "processBlock".
2. pushBlock creates block and check in validity outside syncronization.
3. Especially dangerous is checks using lastBlock.
4. Than inside syncronization it set processed block as lastBlock, broking what's done in parallel thread.

I think, whole pushBlock() must be sync'ed on blocks.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!