cyfrin / security-and-auditing-full-course-s23 Goto Github PK
View Code? Open in Web Editor NEWThe ultimate, most advanced, security, DeFi, assembly, web3 auditor course ever created.
License: GNU General Public License v3.0
The ultimate, most advanced, security, DeFi, assembly, web3 auditor course ever created.
License: GNU General Public License v3.0
Lesson 1
https://youtu.be/pUWmJ86X_do?si=MzOuDD8K-r8NJu7h&t=5507
In the section 1 of Security and Auditing course after the 12th topic in which Patrick says we'll look at some upgradeable contracts examples in the next video there is no clip of upgradeable contracts in the next video and instead it jumps to selfdestruct and the next video number 14 which is fork test is included in the 13. selfdestruct video only so there is repetition of that on the updraft while on YouTube everything is fine.
Lesson 1
https://youtu.be/pUWmJ86X_do?si=xRf3iXmIybjkJTFL&t=6165
Windows
At this part of the video, the student is encouraged to play with SmallProxy.sol from:
https://github.com/Cyfrin/foundry-upgrades-f23/blob/main/src/sublesson/SmallProxy.sol
Great course!
Lesson 3
https://updraft.cyfrin.io/courses/security/first-audit/exploit-public-data?lesson_format=transcript
Windows
In section 3 lesson 10, there may be a mistake in the code. In written lessons on the website, there should be images of the code instead, it is displaying the HTML code which should not be happening. When I inspected the code I saw the img tag was in double quotes, may be that is the reason.
Lesson 7
No response
In section 7, lesson 22 jumps back to repeat lesson 8 and then proceeds to Lesson 9 instead of Lesson 23.
Lesson 1
https://www.youtube.com/watch?v=Vy9p6PgNPWg
Repeated video in Upgradeable contracts, it is the same as the Encoding function.
Lesson 1
In the section 1.4 video not found on updraft
In The Review section of course
Link:
https://updraft.cyfrin.io/courses/security/review/upgradeable-contracts
In the Review Section, Go towards 'Upgradeable contracts' video & you can see that It is showing the previous video .
In 'Small proxy' it's showing previous video ''Upgradeable contracts'. Do check it out.
Thanks
Other (please describe)
https://www.youtube.com/watch?v=rjaLKCmQf7g
The LinkedIn points to some alchemy link.
I think that should point to something different related to Linkedin.
Other (please describe)
No response
Windows
In the written section of Lesson 16 command line "forge anvil" was written which throws error unrecognized sub-command on terminal. The correct command is "anvil," as accurately demonstrated in the corresponding video section.
Arbitrary List:
The high level coverage of signatures is fine for the purposes of the content, but it leaves quite a few unanswered questions such as the actual definitions and derivations of the v, r and s
values. Expanding with content focused on signatures would be good!
MOAR Remix/Vulnerability examples. Seeing the bug in action is awesome.
Lesson 13
https://updraft.cyfrin.io/courses/security/bridges/signatures-summarized
This video detail page shows
Network Error
A network error caused the media download to fail.
Lesson 1
https://updraft.cyfrin.io/courses/security/review/upgradeable-contracts
In section 1: Review
Instead of upgradeable contracts topic video, it contains video explaining encoding function
Instead of small proxy topic video, it contains video explaining upgradeable contracts
Instead of self destruct topic video, it contains video explaining small proxy
In the section 1, lesson 14 video, it contains video explaining self destruct and fork tests
It is kinda complicated to work with cyfrin updraft website`s video on half screen mode. You can compare it with Yt - as an opposite i can properly see video in Yt in a same mode. I know i can click the link and open it on Yt as well, but i believe it will be better to do something with UI of website. P.S. Patrick you awesome lecturer <3
Originally posted by kildren-coder June 18, 2024
At the end of the video, we need to provide suggestions for detecting duplicate users. The approach in the video is correct, but the code provided contains errors.
The code is as follows:
+ mapping(address => uint256) public addressToRaffleId;
+ uint256 public raffleId = 0;
.
.
.
function enterRaffle(address[] memory newPlayers) public payable {
require(msg.value == entranceFee * newPlayers.length, "PuppyRaffle: Must send enough to enter raffle");
for (uint256 i = 0; i < newPlayers.length; i++) {
players.push(newPlayers[i]);
+ addressToRaffleId[newPlayers[i]] = raffleId;
}
- // Check for duplicates
+ // Check for duplicates only from the new players
+ for (uint256 i = 0; i < newPlayers.length; i++) {
+ require(addressToRaffleId[newPlayers[i]] != raffleId, "PuppyRaffle: Duplicate player");
+ }
- for (uint256 i = 0; i < players.length; i++) {
- for (uint256 j = i + 1; j < players.length; j++) {
- require(players[i] != players[j], "PuppyRaffle: Duplicate player");
- }
- }
emit RaffleEnter(newPlayers);
}
.
.
.
function selectWinner() external {
+ raffleId = raffleId + 1;
require(block.timestamp >= raffleStartTime + raffleDuration, "PuppyRaffle: Raffle not over");
According to the given code, all players are checked after being added to the array and addressToRaffleId[newPlayers[i]] = raffleId
is set. Then, checking require(addressToRaffleId[newPlayers[i]] != raffleId, "PuppyRaffle: Duplicate player")
obviously leads to a situation where the require check cannot pass.
We expect that before a player is added to the queue, their raffleId should be checked to see if it matches the raffleId of the current round. If it matches, it means they have already joined this round of the raffle and should not be added again.
Considering the impact of default values, the correct code should be as follows:
+ mapping(address => uint256) public addressToRaffleId;
+ uint256 public raffleId = 1; // raffleId = 0 will lead to fail to add new player
.
.
.
function enterRaffle(address[] memory newPlayers) public payable {
require(msg.value == entranceFee * newPlayers.length, "PuppyRaffle: Must send enough to enter raffle");
for (uint256 i = 0; i < newPlayers.length; i++) {
+ require(addressToRaffleId[newPlayers[i]] != raffleId, "PuppyRaffle: Duplicate player");
players.push(newPlayers[i]);
+ addressToRaffleId[newPlayers[i]] = raffleId;
}
- // Check for duplicates
- for (uint256 i = 0; i < players.length; i++) {
- for (uint256 j = i + 1; j < players.length; j++) {
- require(players[i] != players[j], "PuppyRaffle: Duplicate player");
- }
- }
emit RaffleEnter(newPlayers);
}
.
.
.
function selectWinner() external {
+ raffleId = raffleId + 1;
require(block.timestamp >= raffleStartTime + raffleDuration, "PuppyRaffle: Raffle not over");
```</div>
In the security-and-auditing-full-course-s23 repo:
Lesson 2
No response
Not a video mistake, just a small typo
Originally posted by allwin199 February 20, 2024
Vs code Extension: Markdown PDF
To create a page with a logo and titles
<!DOCTYPE html>
<html>
<head>
<style>
.full-page {
width: 100%;
height: 100vh; /* This will make the div take up the full viewport height */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.full-page img {
max-width: 200;
max-height: 200;
margin-bottom: 5rem;
}
.full-page div{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<div class="full-page">
<img src="./logo.svg" alt="Logo">
<div>
<h1>Puppy Raffle Protocol Audit Report</h1>
<h3>Prepared by: Prince Allwin</h3>
</div>
</div>
</body>
</html>
<!-- Your report starts here! -->
.
.
.
Example of a Report created using this extension
@PatrickAlphaC Is there any downside to this method?
If there is no downside, we can add this to audit-report-templating and link it in the security-and-auditing-full-course-s23 Readme.
scroll down to Scoping & Reconnaissance: Boss Bridge
Lesson 4
https://youtu.be/pUWmJ86X_do?t=30463
PuppyRaffle Audit -> H-3 Integer Overflow -> Proof of Concept -> 4th point:
- You will now not be able to withdraw, due to this line in
PuppyRaffle::withdrawFees
:require(address(this).balance == uint256(totalFees), "PuppyRaffle: There are currently players active!");Although you could use
selfdestruct
to send ETH to this contract in order for the values to match and withdraw the fees, this is clearly not what the protocol is intended to do.
I think that last line is a mistake.
As far as I understand selfdestruct
can increase a contract's balance
. But, address(PuppyRaffle).balance > totalFees
after the integer overflow. It makes no sense to increase address(PuppyRaffle).balance
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.