TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Websites can change content inside a selection

154 点作者 void_nill超过 5 年前

28 条评论

danShumway超过 5 年前
How exactly would you block this behavior without getting rid of a substantial portion of web functionality, even around simple document styling?<p>It&#x27;s not a Javascript problem. To make it impossible, we&#x27;d need to get rid of invisible spans. Text overflow can&#x27;t be hidden. This means you can&#x27;t display extra text to screen readers, since that&#x27;s invisible text. Also, non-system fonts are right out, because they can contain invisible characters, or even be remapped so that the wrong characters display.<p>The &#x27;solutions&#x27; I&#x27;m seeing proposed on this issue are hacks. If this is a real problem, the real answer is to just make the clipboard visible when you copy, preferably on an OS level (since literally every format&#x2F;platform that allows bundling custom fonts is vulnerable to this, including PDFs).<p>Prefer security solutions that are simple and universally understandable, rather than solutions that rely on adding a bunch of code to plug part of a hole. Doing real-time analysis to figure out whether text is visible doesn&#x27;t fix the whole problem, and is highly error prone.<p>I think Mozilla is right to reject this. If you&#x27;re coming up with hacks about per-domain character recognition that will end up behind some kind of permission prompt that users will click through without reading anyway... that&#x27;s a sign you haven&#x27;t thought hard enough about what the problem is. When something is written to the clipboard, just bring up a notification on-screen and show the user what they copied, and give them the option to inspect&#x2F;edit it in more detail. The best thing is that&#x27;s an OS-level mitigation, and not another weird, buggy implementation detail that makes it harder to build or inspect a web browser.
评论 #21380101 未加载
评论 #21381697 未加载
评论 #21383872 未加载
评论 #21384099 未加载
WA超过 5 年前
This has been a &quot;bug&quot; for a long time with exactly the same behavior that is described here. Copy&amp;paste from a news article or a blog and have something like &quot;read more at &lt;URL&gt;&quot; inserted.<p>It&#x27;s also not Firefox-specific. Same behavior happens in Safari and Chrome.<p>But yeah, it makes total sense to point this out that hijacking the clipboard is probably not a good idea and this might be a security issue.
rhn_mk1超过 5 年前
I find the reasons not to mitigate this in any way short-sighted.<p>Disabling the copying of invisible text will not mitigate all the instances. Disabling the modification via clipboard events won&#x27;t either. Nor will disabling the ability to see user&#x27;s selection.<p>But each of them would cut off a lot of offenders already (defense in depth-like), and each change in this direction would give credibility to the idea that the expected behaviour is to copy what&#x27;s visible. With all of them implemented, it would become politically much more palatable to plug the last holes and let copy-paste behave 100% as users expect.
评论 #21378569 未加载
评论 #21379767 未加载
scarygliders超过 5 年前
Okay, I&#x27;ve read all the responses so far at time of writing.<p>Lots of technical solutions which would break the browser&#x2F;site&#x2F;web&#x2F;whatever.<p>What I haven&#x27;t seen is;<p>Why not, on highlighting text to copy, a small window pops up in one of the corners of the browser, and whatever text would be copied to the clipboard, is instead bunged into this window?<p>A sort of intermediate step as it were.<p>Then if you&#x27;re satisfied that the content is what you want, hit some &#x27;really copy to clipboard&#x27; button. The window goes away, the text is copied to clipboard.<p>A built-in text window. Because most people who use browsers aren;t going to go to the bother of copying and pasting into a text editor (Notepad, Kwrite, whatever) to vet the contents before pasting it wherever.<p>So make the intermediate step mandatory.
评论 #21383018 未加载
评论 #21384111 未加载
评论 #21383005 未加载
asah超过 5 年前
A slightly more nuanced proposal:<p>1. Detect the first time a site (domain? URL?) attempts to copy something that&#x27;s not visible. Algorithm TBD but we can start by warning too frequently.<p>2. Ask the user if this is a trusted site and deny, allow once, allow always. Users presumably select allow-always for apps like Google sheets.<p>3. (advanced) detect if enough people over long enough time select allow-always and then allow users to go with the herd. I&#x27;m talking 10+mm users not 10k, i.e. hard to cheat.<p>4. (Advanced) option to see what&#x27;s in the proposed copy buffer.<p>(Obviously this all assumes that publishing sites have web security measures in place e.g. no raw HTML...)
评论 #21378435 未加载
评论 #21384124 未加载
skibz超过 5 年前
One of the people active in the thread concludes that:<p>&gt; The right approach if you&#x27;re worried about these vectors is: never paste things off internet sites you don&#x27;t trust directly into your terminal.<p>I&#x27;d like to add that disabling JavaScript also seems like a sensible option, unless that prevents the site from rendering, of course.
评论 #21378258 未加载
vezycash超过 5 年前
Off topic: I&#x27;ve been wanting a:<p>&#x27;Exclude on this site,&#x27; &#x27;Run on this site only&#x27; option for Firefox addons. A site Whitelist &#x2F; Blacklist menu for all Firefox addons.<p>It should be accessible from the toolbar, so I can click to restrict &#x2F; allow the current domain without needing to type (that&#x27;s for the extension details page).<p>This will be massive privacy help.
codezero超过 5 年前
As someone who spent quite a while understanding the differences between innerText and textContent between different browsers and browser versions, I completely empathize with the POV that it&#x27;s not just as simple as not letting someone copy what isn&#x27;t &quot;visible.&quot; It&#x27;s really hard to define visibility of text in a simple straightforward way.
lilyball超过 5 年前
&gt; <i>Note that this is a horrible security issue. The newlines cause the text to be immediately executed if I pasted it into a command line window.</i><p>Modern terminals &amp; shells guard against this. Modern *nix terminals emit special &quot;paste bracketing&quot; codes around the pasted text, which the shell can use to turn off handling of newline (such that you just get a multiline input instead of executing text). I don&#x27;t know about Windows but I would hope Windows terminals have similar capabilities.
评论 #21383185 未加载
Mathnerd314超过 5 年前
There are some extensions that help, e.g. <a href="https:&#x2F;&#x2F;github.com&#x2F;aaronraimist&#x2F;DontFuckWithPaste" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aaronraimist&#x2F;DontFuckWithPaste</a>. It just allows you to paste, IIRC, not copy, but if someone was really annoyed I guess they could make one for copying. And NoScript had some clickjacking protection, but it hasn&#x27;t been ported to the WebExtension yet.<p>Typically though these are done with third-party scripts and just blocking the script is sufficient.<p>In this case it isn&#x27;t so uBlock has a rule: <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;uBlockOrigin&#x2F;comments&#x2F;7l54xr&#x2F;metro_copyjacking_filter&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;uBlockOrigin&#x2F;comments&#x2F;7l54xr&#x2F;metro_...</a>
osamagirl69超过 5 年前
Hasn&#x27;t this been the expected behavior since the dawn of the web 2.0? Next he is going to complain that websites can have a hyperlink that says example.com but points to badexample.com! And worse yet, they can use js to hide their tracks! (ie, google search click redirects)
评论 #21378129 未加载
评论 #21378016 未加载
评论 #21378755 未加载
psykus超过 5 年前
A grantable permission would be nice. &quot;This site would like to modify your clipboard&quot;
评论 #21380161 未加载
jawns超过 5 年前
If there really are technical reasons not to change this behavior, then shaming sites that employ it to do bad things seems like a next-best solution.<p>Perhaps a browser extension that maintains a list of offenders and alerts the user that the site injects bad things (including marketing and promotional stuff) into copied text?
mikl超过 5 年前
This is one of those cases where useful features for web applications (ie. custom copy &amp; paste logic) enables dark UI patterns for the web in general. Neigh impossible to solve without breaking existing apps.
_bxg1超过 5 年前
The challenge around issues like this, is that the informal separation between &quot;trusted&quot; and &quot;untrusted&quot; software used to be formalized (by coincidence) as a <i>technical</i> distinction: software you installed to your computer could do whatever it wanted, but you put more thought into whether or not to use it in the first place than you do when you click a link.<p>Now that those cases are combined into a single technical platform, it&#x27;s difficult to tease them back apart when it comes to level of trust.
greggman2超过 5 年前
changing this behavior will break many sites. slack, discourse, Gmail chat&#x2F;Hangouts , Facebook messenger, and I&#x27;m guessing discord etc.<p>Most chat sites seem to want their own emoji. Gmail replaces emoji with Google&#x27;s. Discourse claims to do it to make it consistent across devices and they got angry when I asked for an option to disable the conversion and just leave things plain text.<p>In order for all of these to work they have to let you select your chat messages with their embedded images and then convert that back to utf8 if you copy
评论 #21378839 未加载
评论 #21379643 未加载
InsomniacL超过 5 年前
1) Remember the selection when the selection is made, if content changes ignore until a re-selection is made or un-select when it changes. 2) for hidden content, when selected display a permission box 2.1) permission box states, &quot;hidden content was selected but Chrome removed it, to allow hidden content to be selected for this website click allow &quot; [Allow] [Ignore] obviously it needs finessing but it seems possible?
staeke2超过 5 年前
I think a sensible ”solution” might be for OS vendors (usually not that different from browser vendors) to continuously monitor the clipboard just like anti-virus software is monitoring the file system for viruses. And block access (or condition it with hard warning modal) on pasting flagged text. Possibly allow pasting to same site without check.
boomlinde超过 5 年前
I am glad to see this raised as a bug, even if the fix would be a huge breaking change. It highlights one of many ways that growth of complexity and API surface of the browser has become a serious security issue.<p>Maybe merging the concepts of a hypertext document layout system and an application platform wasn&#x27;t a good idea.
btschaegg超过 5 年前
I&#x27;d just like to point out that I find the reflex of &quot;I don&#x27;t like the comments here, so I lock the bug report down&quot; rather misfortunate.<p>On the same note, I like to see how the discussions here look like a good distributed brainstorming session instead (ignoring a couple of naysayers).
namanaggarwal超过 5 年前
Not important though but the reporter says that they used ctrl+v to copy. Is that right or a typo ?
评论 #21377992 未加载
shujito超过 5 年前
I&#x27;d disable javascript on the offending website (not web apps, but blogs, news sites, or the likes) for anything JS related that causes annoyances, like popups or unsolicited modals or alerts.
评论 #21379883 未加载
hamandcheese超过 5 年前
The people most likely to be actually harmed by this are developers, right (i.e. pasting in to a terminal)? And shouldn’t we of all people understand that there isn’t much practical difference between opening a shady website, and running a shady executable binary? And if pasting straight into your terminal then there literally is no difference whatsoever.<p>Aside from shady websites, the other main attack vector would be, e.g., a XSS vulnerability on Stack Overflow. And browser vendors do seem to take XSS very seriously, and there are a number of ways to mitigate those.<p>Scummy news site injecting social links in to copied text? That to me sounds like a people problem, not a software problem.
评论 #21378930 未加载
评论 #21378943 未加载
adrr超过 5 年前
Attacking shell seems to be an exploit that could maybe affect 1 out 50 people. Attack the url bar with &quot;javascript:&quot; and you can have XSS attack on any site.
shmerl超过 5 年前
When such fooling around happens, you can select, then do &quot;view selection source&quot;, then when source opens, already copy with Ctrl+C.
banger180超过 5 年前
An alert that you did not copy what you think you copied would not be out of place in my opinion.
评论 #21378912 未加载
uptown超过 5 年前
Wait till people find out what Facebook does with the device clipboard.
ArchReaper超过 5 年前
Why is this being posted? This &quot;issue&quot; has existed for a long, long time, and it is not specific to any single browser.
评论 #21378993 未加载
评论 #21379708 未加载