Bitcoin Forum
May 07, 2024, 06:45:00 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)
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 05:19:16 AM
 #361

I'll just wait until you guys fix their broken code for them and then i'll fork it.

U r one of the hundreds who waits for this. Grin
1715107500
Hero Member
*
Offline Offline

Posts: 1715107500

View Profile Personal Message (Offline)

Ignore
1715107500
Reply with quote  #2

1715107500
Report to moderator
1715107500
Hero Member
*
Offline Offline

Posts: 1715107500

View Profile Personal Message (Offline)

Ignore
1715107500
Reply with quote  #2

1715107500
Report to moderator
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715107500
Hero Member
*
Offline Offline

Posts: 1715107500

View Profile Personal Message (Offline)

Ignore
1715107500
Reply with quote  #2

1715107500
Report to moderator
1715107500
Hero Member
*
Offline Offline

Posts: 1715107500

View Profile Personal Message (Offline)

Ignore
1715107500
Reply with quote  #2

1715107500
Report to moderator
1715107500
Hero Member
*
Offline Offline

Posts: 1715107500

View Profile Personal Message (Offline)

Ignore
1715107500
Reply with quote  #2

1715107500
Report to moderator
liyi3c
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile
January 05, 2014, 05:24:20 AM
 #362

Code:
synchronized (senderAccount) {

senderAccount.setBalance(senderAccount.balance + (transaction.amount + transaction.fee) * 100L);

}

I just wonder why not setUnconfirmedBalance back here
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 05:25:44 AM
 #363

Obviously: Before typing this post, I tried the latter method on my local 0.5.0 client and it didn't work. So I guess this has been fixed by now.

Published version is also immune to this attack coz out-of-memory is caught by try-catch.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 05:29:27 AM
Last edit: January 05, 2014, 06:55:38 AM by Come-from-Beyond
 #364

Code:
synchronized (senderAccount) {

senderAccount.setBalance(senderAccount.balance + (transaction.amount + transaction.fee) * 100L);

}

I just wonder why not setUnconfirmedBalance back here

This code processes confirmed transactions.
lophie
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1001

Unlimited Free Crypto


View Profile
January 05, 2014, 06:47:29 AM
 #365

BEAUTIFUL, Programming nazi here are just trolls who imitate their tutors disgruntle at them when they were learning to program. Like the others, I am etching to fork it! But not a different chain... or maybe Tongue

Will take me a while to climb up again, But where is a will, there is a way...
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 07:46:37 AM
 #366

Shouldn't there be an || account.getEffectiveBalance() < 0 in the code above?

Does the Genesis account forge when unlocked without this restriction?


Imagine that... a situation where generating a block would not be desirable!!!   Wink

Target for genesis account will be negative, but it's still a good idea to use "<=" instead of "==".

This is not the flaw.
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 05, 2014, 09:11:59 AM
 #367

Shouldn't there be an || account.getEffectiveBalance() < 0 in the code above?

Does the Genesis account forge when unlocked without this restriction?


Imagine that... a situation where generating a block would not be desirable!!!   Wink

Target for genesis account will be negative, but it's still a good idea to use "<=" instead of "==".

This is not the flaw.
Target is negative, hit is negative to. Comparision will be still "hit<target". Absolute value of target will be very big, so probability of forging will be very low. Omnipotence paradox Cheesy
gsan1
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 05, 2014, 09:27:04 AM
 #368

Code:
if (secretPhrase.length() < 30) {

    response.put("secretPhraseStrength", 1);

} else {

    response.put("secretPhraseStrength", 5);

}

The only thing that gets checked at the moment is the length of the password. Wouldn't it be appropriate to check for other things? Everyone will agree that "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (31 x a) is not more secure than "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (30 x a). When the software finds distribution and DAUs will use it, we need to tell them how a secure password has to look like. So we need at least a check that upper/lower-case letters, numbers and special characters are part of the password.

Wouldn't it be nice to have additional a password generator implemented in NXT? On the other hand that could become a problem, if users just generate a password and don't remember it afterwards.
ImmortAlex
Hero Member
*****
Offline Offline

Activity: 784
Merit: 501


View Profile
January 05, 2014, 09:35:13 AM
 #369

Code:
if (secretPhrase.length() < 30) {

    response.put("secretPhraseStrength", 1);

} else {

    response.put("secretPhraseStrength", 5);

}

The only thing that gets checked at the moment is the length of the password. Wouldn't it be appropriate to check for other things? Everyone will agree that "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (31 x a) is not more secure than "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" (30 x a). When the software finds distribution and DAUs will use it, we need to tell them how a secure password has to look like. So we need at least a check that upper/lower-case letters, numbers and special characters are part of the password.

Wouldn't it be nice to have additional a password generator implemented in NXT? On the other hand that could become a problem, if users just generate a password and don't remember it afterwards.
This is the function of client software. I do not think that developers of NRS (reference software) will do anything regarding password generation for users. Btw, it was discussed a lot of times.
vamdor
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 05, 2014, 10:06:42 AM
Last edit: January 05, 2014, 10:32:27 AM by vamdor
 #370

Valid assumption. U could follow my way - try to create a model and run it. My results show that max difference in number of forged blocks between Alice owning 1M of coins and million Bobs with 1 NXT each is less than 1/1000 of the normalized base target.

Instead of running simulations I did the math and the effect is much smaller than I expected. For example someone having 33% stake can get up to 36% of the blocks if the rest of the network are many small non-colluding participants.

Could u post ur math plz?

So for those not following: A user may have many small accounts instead of one, and may sometimes be able to choose which one to use for forging in a way that the next block also belongs to him.

Of course there are some limitations because of the fees, but for now let's assume that a user has "p" stake [0..1], and it is available in many small accounts: specifically the number of accounts is significantly higher than 1440, so that we can ignore that the 1440 block waiting period disables some parts of the accounts. We also assume that all the other accounts are many small non-colluding users.

Now if this user has a probability "x" of creating a block, then we can express that probability as a recursive formula. Generating the next block will happen with probability:

x*(p+(1-p)*p^2) + (1-x)*p = x

The second part means that with probability (1-x) someone else is generating the block, the account has no word in the selection process, so he will get his fair "p" chance in this case.

However when with probability "p" it happens that the account with the best chances is one of his owns, he can also check whether he also has the second best account. So in this case there is a "p" chance of generating the next block in the "fairly deserved way", by choosing the best block which also happens to grant the second block, but when this isn't true (chance (1-p)), he can check whether he has the second best block too (*p) , and whether it grants him the next block too. (this also happens with "p" probability) So this case adds an additional chance of (1-p)*p*p for this branch.

Solving the equation gives x = p / (p^3 - p^2 +1)

As I said this is not a big difference. Gives some incentive for colluding though, a few players with 5%-10% stakes each may decide that the few extra percents are worth grabbing.
ricot
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
January 05, 2014, 10:10:31 AM
 #371

Obviously: Before typing this post, I tried the latter method on my local 0.5.0 client and it didn't work. So I guess this has been fixed by now.

Published version is also immune to this attack coz out-of-memory is caught by try-catch.

Huh OutOfMemoryError isn't a catchable exception because the memory of the VM has been compromised!
(Hence the name Error, not Exception Wink)

Also see the following little test code to verify:
Code:
public class Test {
  public static void main(String[] args) {
    try{
      long[] l = new long[Integer.parseInt(args[0])];
    }catch(Exception e){
      System.out.println("foo");
    }
    System.out.println("bar");
  }
}

If started with INT_MAX as a parameter, it shows a java heap space JVM exception and neither "foo" nor "bar".

If you guys think, that a catch(Exception e) safes you from those kind of things... I'm speechless.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 10:17:51 AM
 #372

Obviously: Before typing this post, I tried the latter method on my local 0.5.0 client and it didn't work. So I guess this has been fixed by now.

Published version is also immune to this attack coz out-of-memory is caught by try-catch.

Huh OutOfMemoryError isn't a catchable exception because the memory of the VM has been compromised!
(Hence the name Error, not Exception Wink)

Also see the following little test code to verify:
Code:
public class Test {
  public static void main(String[] args) {
    try{
      long[] l = new long[Integer.parseInt(args[0])];
    }catch(Exception e){
      System.out.println("foo");
    }
    System.out.println("bar");
  }
}

If started with INT_MAX as a parameter, it shows a java heap space JVM exception and neither "foo" nor "bar".

U r right. Good catch.

If you guys think, that a catch(Exception e) safes you from those kind of things... I'm speechless.

Fixed.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 10:20:13 AM
 #373

So for those not following: A user may have many small accounts instead of one, and may sometimes be able to choose which one to use for forging in a way that the next block also belongs to him.

Of course there are some limitations because of the fees, but for now let's assume that a user has "p" stake [0..1], and it is available in many small accounts: specifically the number of accounts is significantly higher than 1440, so that we can ignore that the 1440 block waiting period disables some parts of the accounts. We also assume that all the other accounts are many small non-colluding users.

Now if this user has a probability "x" of creating a block, then we can express that probability as a recursive formula. Generating the next block will happen with probability:

x*(p+(1-p)*p^2) + (1-x)*p = p

The second part means that with probability (1-x) someone else is generating the block, the account has no word in the selection process, so he will get his fair "p" chance in this case.

However when with probability "p" it happens that the account with the best chances is one of his owns, he can also check whether he also has the second best account. So in this case there is a "p" chance of generating the next block in the "fairly deserved way", by choosing the best block which also happens to grant the second block, but when this isn't true (chance (1-p)), he can check whether he has the second best block too (*p) , and whether it grants him the next block too. (this also happens with "p" probability) So this case adds an additional chance of (1-p)*p*p for this branch.

Solving the equation gives x = p / (p^3 - p^2 +1)

As I said this is not a big difference. Gives some incentive for colluding though, a few players with 5%-10% stakes each may decide that the few extra percents are worth grabbing.


Nxt forging is a Poisson process. Does "x*(p+(1-p)*p^2) + (1-x)*p = p" take this into account?
vamdor
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 05, 2014, 10:30:23 AM
 #374

Nxt forging is a Poisson process. Does "x*(p+(1-p)*p^2) + (1-x)*p = p" take this into account?
That's what I am saying. It is intended to be a Poisson process, and it is as long as you are using the algorithm in the published source. But someone may decide to "optimise" it further for their own benefit. In that case it isn't strictly a Poisson process anymore, as he is creating a block, he has a slightly higher chance to create the next one too.

Also I made a typo when copying: it's x*(p+(1-p)*p^2) + (1-x)*p = x , the solution is the same
getfun12345
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
January 05, 2014, 10:30:49 AM
 #375

I found that every time made a transaction need to wait for a long time.
Can we change this code
Code:
JSONArray transactionsData = new JSONArray();
transactionsData.add(transaction.getJSONObject());
peerRequest.put("transactions", transactionsData);

[b]Peer.sendToAllPeers(peerRequest);[/b]

JSONObject response = new JSONObject();
response.put("response", "notifyOfAcceptedTransaction");
user.pendingResponses.offer(response);

to

Code:
JSONArray transactionsData = new JSONArray();
transactionsData.add(transaction.getJSONObject());
peerRequest.put("transactions", transactionsData);

JSONObject response = new JSONObject();
response.put("response", "notifyOfAcceptedTransaction");
user.pendingResponses.offer(response);

[b]Peer.sendToAllPeers(peerRequest);[/b]

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

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 10:42:01 AM
 #376

...as he is creating a block, he has a slightly higher chance to create the next one too.

Why?

Edit: Assuming that moved coins r excluded from effective balance for 1440 blocks.
vamdor
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
January 05, 2014, 10:44:26 AM
 #377

...as he is creating a block, he has a slightly higher chance to create the next one too.

Why?
Because there is a chance that he not only has the first winning ticket of the "who's gonna forge" lottery, but also the second one. In this case he can choose which one to use: if the second one makes him the winner for the next block too, he chooses that, instead of the first one.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 10:44:38 AM
 #378

I found that every time made a transaction need to wait for a long time.
Can we change this code
Code:
JSONArray transactionsData = new JSONArray();
transactionsData.add(transaction.getJSONObject());
peerRequest.put("transactions", transactionsData);

[b]Peer.sendToAllPeers(peerRequest);[/b]

JSONObject response = new JSONObject();
response.put("response", "notifyOfAcceptedTransaction");
user.pendingResponses.offer(response);

to

Code:
JSONArray transactionsData = new JSONArray();
transactionsData.add(transaction.getJSONObject());
peerRequest.put("transactions", transactionsData);

JSONObject response = new JSONObject();
response.put("response", "notifyOfAcceptedTransaction");
user.pendingResponses.offer(response);

[b]Peer.sendToAllPeers(peerRequest);[/b]



No. A user should see when his node completes broadcasting a transaction.
Come-from-Beyond (OP)
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 05, 2014, 10:46:00 AM
 #379

Because there is a chance that he not only has the first winning ticket of the "who's gonna forge" lottery, but also the second one. In this case the can choose which one to use: if the second one makes him the winner for the next block too, he chooses that, instead of the first one.

What is more profitable then? Forge using 1 big account (1M NXT) or a lot of small ones (100 x 10K NXT)?
Meizirkki
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500



View Profile
January 05, 2014, 10:48:39 AM
 #380

...as he is creating a block, he has a slightly higher chance to create the next one too.

Why?
Because there is a chance that he not only has the first winning ticket of the "who's gonna forge" lottery, but also the second one. In this case he can choose which one to use: if the second one makes him the winner for the next block too, he chooses that, instead of the first one.
Someone reported seeing this in the blockchain frequently. Same node forging 2 blocks in a row.
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!