HNHacker News
TopNewBestAskShowJobs

hmsimha

659 karma · joined November 10, 2012

https://www.linkedin.com/in/hartsimha/

https://github.com/harts

https://github.com/hmsimha

submissionscomments
hmsimha··on HTTP/2-exclusive threats caused by implementation flaws and RFC imperfections
> But more importantly, you should investigate how your LB or webserver talks to the web app. In many cases that part won't be TLS encrypted and therefore on an HTTP/1.1 channel.

Or even HTTP 1.0 . I found out recently while inspecting some requests in the upstream server that nginx was using HTTP 1.0 after terminating TLS. I was dumbfounded that this was still the default.

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#pro...

hmsimha··on How to boost your popularity on OkCupid using CSRF and a JSON type confusion
Defaulting to SameSite=lax is a (relatively) recent development, as per the doc you linked.

Yes, I don't think cookies with SameSite=Lax will be sent to a cross-domain host when the request type is a POST, even when the navigation is top-level. Though they will for GET and HEAD.

Defaulting to SameSite=Lax has only been in Chrome since Feb of last year, and in Edge since October of last year. It has yet to land in Firefox or Safari.

hmsimha··on How to boost your popularity on OkCupid using CSRF and a JSON type confusion
I believe this also requires that OKCupid has not set the 'SameSite=lax' attribute on their cookies, which is good practice as well; the browser won't send the user's cookies on cross-origin POST, PUT, PATCH, or DELETE requests when this attribute is set.

So this exploit is really the confluence of failing to follow 2 standard security practices, as well as another unfortunate configuration quirk:

- Failing to set SameSite=lax on their session cookie attribute - Not using a CSRF token to authenticate on unsafe HTTP actions - Not checking the content-type of API requests (though I'm not sure to what extent this is considered bad practice)

hmsimha··on Docker in Production: A History of Failure (2016)
Containerd is the docker runtime, so it's still used to run/manage containers on the kubelet. Crio is another option: https://kubernetes.io/docs/setup/production-environment/cont... . I think the distinction in the docs there is that with just containerd, you don't get all the docker tooling

My understanding is that docker was the most common, but I'm not actually sure if that's still the case. CRI is the interface k8s uses to manage the container engine, and I think CRI-O is the most lightweight, but also gives you less/worse tooling for debugging if you need to drop into a kubelet.

The images are just OCI-spec now, but if memory serves, Docker used a different image format in the past, and it was another containerization company (coreos/rkt) working on an open standard which eventually become OCI

hmsimha··on Why Kubernetes is our modern-day COBOL
Containerization, certainly, but you can run kubernetes just fine without Docker (I was under the impression most large-scale deployments now use Cri-O - https://cri-o.io/#what-is-cri-o)
hmsimha··on JavaScript Is Weird
Devtools can actually be detected to a certain extent - https://github.com/sindresorhus/devtools-detect
hmsimha··on Why bugs might feel “impossible”
Even more worse: it's a stackoverflow from yourself 2 years before, which you then closed because you "figured it out" (without expanding on how)
hmsimha··on Why bugs might feel “impossible”
Relevant XKCD https://xkcd.com/979/
hmsimha··on Australian Federal Police and FBI nab underworld figures using encrypted app
I giggled, but then realized former an0n users might take it as an opportunity for cooperation. Whether or not it is, it may be effective in getting some to turn themselves in for that reason.
hmsimha··on Real-world CSS vs. CSS-in-JS performance comparison
For anyone capable of using React, there's no barrier to 'learning' sass (you can be productive with it in about 30 seconds). Admittedly there might be some additional work around configuring compilation to work with the rest of your build and dev processes, etc. But sass in it's most basic usage (nested selectors) is really what CSS should have been.
hmsimha··on LOL just got kicked out of @ycombinator
For people like me who read the linked twitter thread before reading the comments (admittedly guilty of getting outraged before hearing both sides): There is an "unvote" button underneath the headline.
hmsimha··on Password Managers
Speaking to the section on "Vendor claims"

> An attacker (or malicious insider) in control of the vendor’s network can change the code that is served to your browser, and that code can obviously access your passwords. This isn’t farfetched, altering the content of websites (i.e. defacement) is so common that it’s practically a sport.

Is this actually true? For Lastpass, I would assume the code run in the browser comes from the extension directly, and (for Chrome), the extension comes from the Chrome Web Store. There are some problems here, but in theory the system could be improved so that modifications to the extension in Google Web Store are very obvious, and an attacker couldn't just inject code into the extension and update it without someone noticing immediately.

hmsimha··on Show HN: Transform a CSV into a JSON and vice versa
It would make it much easier for users to visually parse the JSON section if you added `font-family: monospace` to the textarea element
hmsimha··on LibreFoodPantry – a community building FOSS for food pantries
I grew up in the U.S., spent ~7 years volunteering at a soup kitchen (not an actual soup kitchen, but a program which cooked and served meals to the public), and I had no idea what "food pantry" was. The term I'm familiar with is "food bank". Maybe it's regional? I was living in Memphis, TN
hmsimha··on Second-guessing the modern web (2020)
Just to add to the above, this is specifically when your pages are server-side rendered. Hydration is a concept of taking a server-rendered page and making it interactive with Javascript.

You can have your NextJS/React app server-rendered, and then users visiting a page will get the page. Clicking links within the application will use Javascript routing to load the part of the application that needs to be displayed (and prevent the default navigation from clicking said links). I think in practice it's more likely for users to fall back to default navigation which then relies on full server rendering when they have Javascript disabled, than it is because they've clicked before the front-end router has started working.

Also, before this thread I didn't realize React itself could be server-rendered (I thought that was the distinguishing point of Nextjs). Is it common to use non-next React for SSR?

hmsimha··on Learn CSS
Ahh OK, interesting. That seems like more of an HTML issue than a CSS one (putting the close button element outside of the container element which it's associated with). I'll carry on doing things the way I already do then.

Thanks for the detailed response

hmsimha··on Learn CSS
> Or, using absolute position to, say, anchor a close button to the top right of an element. Sure, the way you did it happened to put it visually in the right spot, but it's not actually in the right spot according to the layout engine because its offset parent is not the element you're trying to anchor it to, so if other content gets put in there eventually, it will be in the wrong spot.

I'm absolutely guilty of this one and would love to know the correct way to do it if you have a resource handy. I generally feel like working with CSS (or ideally Tailwind now) is an uphill battle. In my defense I would also give the container a padding which should (in theory) prevent any of its statically positioned children from overlapping. But as a full-stack developer I often feel like this is the domain of people who spend their entire career focusing on design, and generally when I'm working in this realm its because we don't have one of those people.

hmsimha··on Learn CSS
The implication here seems to be "when using HTML semantically", because I think everything you're talking about can be done with CSS if you're willing to abuse HTML.

Take this CSS accordion which uses hidden form elements: https://codepen.io/raubaca/pen/PZzpVe

I agree that if you want to use HTML semantically *and* have intuitive UX/UI, you're very limited in what you can do without Javascript, but this isn't *just* a failing of CSS; rather, I think it's due to the design of HTML and CSS historically being to the exclusion of the other, rather than with a symbiotic relationship in mind. Go far enough back into the history of web standards and it kind of makes sense though; HTML and precursors had been in development for years before CSS was standardized

hmsimha··on Offline-First PWA for Plotly Visualization of CSV via SQLite
This seems really neat. Curious if you saw this magic SQLite -> Static file tool shared here a couple of weeks ago: https://news.ycombinator.com/item?id=27016630

IIUC It would enable this tool to work with a dataset in sqlite that could be recompiled as static files periodically, and the relevant queries could be made on the front-end without having to load the whole data-set or select a CSV file from the filesystem. Would also lead to much better performance if you want users to be able to host generated charts on a static file server, presumably the output could be committed to git and then synced to a github pages or something.

edit: It appears the author of that tool is using Plotly as well in the demo website. An integration of these would be incredible.

hmsimha··on Big list of HTTP static server one-liners
I don't think I am.

If I'm testing a react app on localhost:3000, and it normally calls out to an api of mine also, I may want to feed it some dummy data. Let's say I use python http.serve on port 5000 in a directory with files in a subdirectory `api` with files `users` and `posts` (which contain JSON data representative of the API response). I then set my react app to use localhost:5000 as the api.

The react app will then make the requests to the api such as `localhost:5000/api/users` and `localhost:5000/api/posts`. The server will respond with the data; however, if the header `Access-Control-Allow-Origin: http://localhost:3000` isn't set, the browser will block this data (probably? unless there are exceptions for localhost)

hmsimha··on Big list of HTTP static server one-liners
You could still want CORS if, for example, you're testing a front-end service that typically calls out to a remote resource. Maybe you typically deploy both same-origin in production, but for dev you want to be able to feed it some specific data. In this case a different port would require CORS.

There are lots of ways around this (put the files in your static folder, embed it into the file you're debugging, use a library which provides mock data, probably more), but it's not inconceivable to just want to be able to point the 'api' configuration param to localhost on a different port so you can just feed it json files from a directory that already has the data you want.

hmsimha··on JWT should not be your default for sessions
You're limited in how much data you can store in a cookie
hmsimha··on JWT should not be your default for sessions
> The CSRF attacks you're describing have been solved by browsers with the SameSite attribute on cookies.

This is only partially true; It requires the users to have browsers which respect this. Which is probably true for 99% of users now, but not 100% (pasting a comment from a project I worked on recently):

/* 'lax' means cookies will not be sent for cross-domain requests on modern browsers, except from top-level navigations with a GET or HEAD request (which are safe). This mitigates CSRF without any additional token handling in browsers Edge (since 2017), Firefox (since 2018), Chrome (since 2016), and Safari (since 2018) */

> In choosing localstorage over HttpOnly cookies, you've put yourself at greater risk in the event of an XSS attack (meaning, an attacker running their javascript code on your own domain).

XSS an issue regardless of whether SameSite is set, they just can't access the session cookies via Javascript (assuming HTTPOnly is also set). An attacker that was able to inject a script into a user's browser on your own domain can get around CSRF protection, and session cookies will be sent. The only disadvantage localstorage has over this is that it can be sent to the attacker's server as well.

I agree cookies are much better for auth* information; if we're using JWT, those can fortunately be put in localstorage also right?

hmsimha··on Two Years of Squash Merge (2019)
This is great! The takeaway for me is that with squash merge you get one commit with all the changes which (optimally) has the full context in the commit message.

My typical workflow is basically the same, but with putting all that context in the merge commit. This allows you to find it with a bit of work (blame to find the commit line, then figure out where that was merged in, then find the merge commit). Squash merge puts all that context in one commit, and keeps a linear history. I had assumed squash merge squashes the commits, then creates a merge commit still, which would mean you'd probably do something like combining messages for each commit in the squash commit message, then capturing the overview in merge commit.

The article says you can still find the individual commits via PR, which is a minor disadvantage as it means you can only do exploration of these via github. If you've deleted the topic branch on github are they still accessible? If it's been garbage collected by git (or never existed locally if you're looking at someone else's changes), is there a way to check them out?

hmsimha··on Stock Market Returns Are Anything but Average
Cryptocurrency staking is effectively the same as dividends for investors, though staking rewards are often more predictable.
hmsimha··on Listen to your to PostgreSQL database in realtime via WebSockets
To be clear, it's not really stream history that I'm after. Just the result of a database query upon connection ( `select all items from table X with time > (now() - 1hr)` )
hmsimha··on Listen to your to PostgreSQL database in realtime via WebSockets
This is something I have an immediate need for (and was about to build myself) to use with a PostgreSQL/TimescaleDB instance. Is it possible to have new subscriptions get up to an hour of historical data before streaming starts, or even better, to supply a parameter to receive historical data from a timestamp?
hmsimha··on Show HN: I built a tool to generate triangulated art from images
This is really cool! I'd be interested in seeing what it looks like to fully drag the image 180 degrees (but can't because the camera resets as soon as the mouseup event fires). Would you accept a small PR to the demo page which does this via a control button instead of on mouseup?
hmsimha··on Green vs. Brown Programming Languages
Not OP, but I would recommend backboneJS[1] or underscore[2]:

  [1]https://backbonejs.org/docs/backbone.html
  [2]https://underscorejs.org/docs/underscore-esm.html
hmsimha··on Starting a TypeScript Project in 2021
When you have to debug something in postgres, are you going to communicate with it by using netcat and writing your own TCP messages by hand, or use psql? Both should work, but you wouldn't say postgres is obfuscating things intentionally so that you have to use psql (or some other postgres client). The fact of the matter is that complex tools are much more useful if they also come with tools to pave over (some of) that complexity and provide a more useful interface for developer experience.

You can debug React apps just fine without the React developer extension, but in some situations it will be much harder. And to elaborate, I work on React full-time and just use the javascript console and debug messages for 99% of my debugging.

← PreviousPage 2 of 13Next →